Codeforces Round 1048 (Div. 1)
E1
Determinant Construction (Easy Version)
Codeforces
3100
原题
← DE2 →
翻译中…

This is the easy version of the problem. The difference between the versions is that in this version, the constraints on the side length of $M$ is larger and the constraints on $t$ is smaller. You can hack only if you solved all versions of this problem.

翻译中…

You are given a non-negative integer $x$. Your task is to construct a square matrix $M$ that satisfies all of the following conditions:

翻译中…
  • The side length of $M$ is at most $80$.
  • Each element of $M$ is either $-1$, $0$, or $1$.
  • The determinant of $M$ is equal to $x$.
  • Each row of $M$ can have at most $3$ non-zero positions, and each column of $M$ can have at most $3$ non-zero positions.
翻译中…

It can be proven that such a matrix always exists.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

The first and only line of each test case contains an integer $x$ ($0 \le x \le 10^7$) — the target value of the determinant.

翻译中…

Output

翻译中…

For each test case, output a single integer $n$ ($1\le n\le 80$) representing the side length of the square matrix $M$.

翻译中…

Then, output $n$ lines, the $i$-th line containing $n$ integers $M_{i, 1}, M_{i, 2}, \ldots, M_{i, n}$ ($M_{i, j} \in \{-1, 0, 1\}$), representing the elements of matrix $M$.

翻译中…

If there are multiple matrices $M$ satisfying the conditions, you may output any of them.

翻译中…

Note

翻译中…

Note that in the third test case, the following solution: $$\begin{pmatrix} 1 & 1 & -1 & 1 \\ -1 & -1 & -1 & 1 \\ 1 & -1 & 0 & -1 \\ 1 & -1 & -1 & -1 \end{pmatrix}$$ is not valid as there are four non-zero positions in the first row of the matrix.

翻译中…

样例

Input #1
3
1
2
4
Output #1
1
1
2
1 -1
1 1
5
1 -1 0 0 0
1 1 1 0 0
0 1 1 -1 0
0 0 1 1 -1
0 0 0 1 1
InputCopy OutputCopy
题目信息
题号
2138E1
时间限制
5 s
内存限制
256 MB
标签
暴力
构造
数学
矩阵
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。