All submissions for this problem are available.### Read problem statements in [Hindi](http://www.codechef.com/download/translated/JAN20/hindi/DFMTRX.pdf), [Bengali](http://www.codechef.com/download/translated/JAN20/bengali/DFMTRX.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/JAN20/mandarin/DFMTRX.pdf), [Russian](http://www.codechef.com/download/translated/JAN20/russian/DFMTRX.pdf), and [Vietnamese](http://www.codechef.com/download/translated/JAN20/vietnamese/DFMTRX.pdf) as well. Dr.D is now fond of matrices. He is particularly interested in Doofish Matrices. A Doofish Matrix of order $N$ is a matrix with $N$ rows (numbered $1$ through $N$) and $N$ columns (numbered $1$ through $N$) such that: - Each element of this matrix is an integer between $1$ and $2N-1$ inclusive. - For each $i$ and $j$ ($1 \le i \le N$, $1 \le j \le 2N-1$), the integer $j$ appears in the $i$-th row and/or in the $i$-th column. Now, for a given $N$, Dr.D is wondering if there is a Doofish Matrix of order $N$. Find such a matrix or determine that it does not exist. If there are multiple solutions, you may find any one. ### Input - The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. - The first and only line of each test case contains a single integer $N$. ### Output For each test case: - First, print a line containing the string `"Hooray"` if a Doofish Matrix of order $N$ exists or `"Boo"` if it does not. - If it exists, print $N$ more lines describing one such matrix. For each valid $i$, the $i$-th of these lines should contain $N$ space-separated integers ― the elements in the $i$-th row. ### Constraints - $1 \le T \le 2,000$ - $1 \le N \le 2,000$ - the sum of $N^2$ over all test cases does not exceed $4 \cdot 10^6$ ### Subtasks **Subtask #1 (29 points):** $N$ is a power of $2$ **Subtask #2 (71 points):** original constraints ### Example Input ``` 2 1 2 ``` ### Example Output ``` Hooray 1 Hooray 3 1 2 3 ```
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.