Problem: Sasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying them further. Instead, he invented his own type of square — a prime square. 

A square of size n × n is called prime if the following three conditions are held simultaneously: 

  * all numbers on the square are non-negative integers not exceeding 10^5; 
  * there are no prime numbers in the square; 
  * sums of integers in each row and each column are prime numbers. 



Sasha has an integer n. He asks you to find any prime square of size n × n. Sasha is absolutely sure such squares exist, so just help him!

Input

The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases.

Each of the next t lines contains a single integer n (2 ≤ n ≤ 100) — the required size of a square.

Output

For each test case print n lines, each containing n integers — the prime square you built. If there are multiple answers, print any.

Example

Input


2
4
2


Output


4 6 8 1
4 9 9 9
4 10 10 65
1 4 4 4
1 1
1 1

Solution (in JAVA):

Solution:
import java.util.*;
import java.lang.*;
import java.io.*;

public class B {
    //-----------Integer Array Input----------
    static int[] readIntArray(int n){
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
            arr[i]=scan.nextInt();
        return arr;
    }
    
    //-----------Long Array Input----------
    static long[] readLongArray(int n){
        long arr[]=new long[n];
        for(int i=0;i<n;i++)
            arr[i]=scan.nextLong();
        return arr;
    }
    
    //------------Boolean Array of Prime number----------------
    static boolean[] isPrimeArray(int e){
        boolean arr[] = new boolean[e+1];
        Arrays.fill(arr,true);
        arr[0]=false;
        arr[1]=false;
        for(int i=2;i*i<=e;i++){
            for(int j=2*i;j<=e;j+=i)
                arr[j]=false;
        }
        return arr;
            
    }
    
    //-----------Prime number Check----------------
    static boolean isPrime(int e){
        for(int i=2;i*i<=e;i++)
            if(e%i==0)
                return false;
        
        if(e==1) return false;
        return true;
    }
    
    //----------------Fast Power ------------------
    static long fastPower(long a,long b){
        long res=1;
        while(b>0){
            if(b%2!=0){
                res=(res*a%MOD)%MOD;
            }
            a=(a%MOD*a%MOD)%MOD;
            b=b>>1;
        }
        return res;
    }
    
    // ----------------Function for GCD(using recursion)-----------
    static long gcd(int a,int b){
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
    }
    
    //---------Function for Counting Set Bits------------
    static int countSetBits(int n){
        int count=0;
        while(n>0){
            n=n&(n-1);
            count++;
        }
        return count;
    }
    
    //-------Function for lastDigit --------
    static boolean lastDigit(int n){
        int a=n;
        while(a>0){
            int ld=a%10;
            if(ld!=4 || ld!=7)
                return false;
            a=a/10;
        }
        return true;
    }
    
    //--------- Swap function--------------
    static int[] swap(int a,int b){
        int temp=a;
        b=a;
        a=temp;
        
        return (new int[]{a,b});
    }
    
    //------MOD----
    static final long MOD=1000000007;
    
    //-----------PrintWriter for faster output---------------------------------
    static final PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
    
    //-----------MyScanner Object----------------------------------
    public static MyScanner scan = new MyScanner();
    
    public static boolean arr[]=new boolean[101];
    
    //-----------------Main method----------------
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		arr=isPrimeArray(100);
		int tc = scan.nextInt();
        for (int i = 0; i < tc; i++) {
            solve();
        }
		pw.close();
	}
	//-----------------Main function Ends here-----------------
	
	//------------Solve function for solving queries-----------------------
	private static void solve() {
		int n=scan.nextInt();
		boolean isPrime=arr[n];
		if(isPrime) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					pw.print(1+" ");
				}
				pw.println();
			}
		}
		else {
			int temp=n;
			while(!arr[temp]) {
				temp--;
			}
			int diff=n-temp;
			if(diff>=2) {
			int i=0;
			for(i=0;i<=n-diff;i++) {
				int tempd=diff;
				for(int j=0;j<n;j++) {
					if(j>=i && tempd>0) {
						pw.print(0+" ");
						tempd--;
					}
					else
						pw.print(1+" ");
				}
				pw.println();
			}
			int test=1;
			for(;i<n;i++) {
				int tempd=diff;
				for(int j=0;j<n;j++) {
					if(j<test){
						pw.print(0+" ");
						tempd--;
					}
					else if(j>=i && tempd>0) {
						pw.print(0+" ");
						tempd--;
					}
					else
						pw.print(1+" ");
				}
				test++;
				pw.println();
			}
			}
			else {
				for(int i=0;i<n;i++) {
					int tempd=diff;
					for(int j=0;j<n;j++) {
						if(j>=i && tempd>0) {
							pw.print(0+" ");
							tempd--;
						}
						else
							pw.print(1+" ");
					}
					pw.println();
				}
				
			}
		}
		
    }
    //------------Solve function ends here-----------------
	
	

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //-----------MyScanner class ends here------------------------
}