Terrible vectors

All submissions for this problem are available.
Read problems statements in Mandarin and Russian. Translations in Vietnamese to be uploaded soon.
You are given an integer N. Consider a vector a of length N^{2} accessible via 0based indexing.
Let's call the following transformation a TVTtransformation (Terrible Vector transformation).
We will call a vector g a good vector if
For some reason, you want to find a vector a of length N^{2} such that it's elements are either 1 or 1 and after applying TVTtransformation (i.e. b), it results in a good vector.
Input
The first line of input contains an integer T denoting the number of test cases. Each test case is described by one line containing one integer N.
Output
For each test case output one line with the word NO if it's not possible to find such vector. Otherwise output YES on the first line and N^{2} spaceseparated integers (each either 1 or 1) on the second  the answer for this test case.
If there are multiple possible answers, output any one of them.
Constraints
 1 ≤ T ≤ 100
 1 ≤ N ≤ 100
Example
Input: 2 1 2 Output: YES 1 YES 1 1 1 1
Subtasks
Subtask 1:(10 points)
 1 ≤ N ≤ 8
Subtask 2: (20 points)
 1 ≤ N ≤ 30
Subtask 3: (30 points)
 1 ≤ N ≤ 60
Subtask 4: (40 points)
 1 ≤ N ≤ 100
Explanation
Sample example 2: After TVTtransformation, the vector will transform to (4, 0, 0, 4) which is a good vector for N = 2
Author:  pavel1996 
Tester:  kevinsogo 
Editorial  http://discuss.codechef.com/problems/TERVEC 
Tags  hadamard, hard, matrices, paleyconst, pavel1996, sept15, sylvesters, williamson 
Date Added:  10072015 
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, SCALA, 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, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 