Universal Cup Judging System

Universal Cup

Süre Sınırı: 3.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

As is well known, the APSP (All-Pairs Shortest Path) problem has a profound connection with min+ matrix multiplication. Today, we want you to solve the following problem:

Given $x$, construct an undirected unweighted connected graph (i.e., all edge weights are 1) such that $\sum_{i=1}^{n} \sum_{j=i+1}^{n} \operatorname{dis}(i, j) = x$. Here, $\operatorname{dis}(i, j)$ represents the shortest path length between node $i$ and node $j$.

This problem is certainly very simple... Unfortunately, your resources are limited, so you hope to find a graph with no more than 85 nodes that meets the requirements.

Input

A single test case contains multiple data sets.

The first line of input is the number of data sets $T$ ($1 \le T \le 2000$), representing the number of data sets contained in this test case.

For each data set, there is one line with an integer $x$ ($1 \le x \le 10^5$), representing the constraint that needs to be satisfied. It is guaranteed that there exists at least one graph with no more than 85 nodes that meets the condition.

Output

For each data set, output the number of nodes $n$ you used on the first line ($2 \le n \le 85$). Then output $n - 1$ lines, where the $i$-th line is a binary string of length $n - i$. The $j$-th character of the $i$-th line is 1 if and only if there is an edge between node $i$ and node $i + j$.

Example

Input

4
1
3
6
8

Output

2
1
3
11
1
4
111
11
1
4
110
10
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.