Problem: A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!

You are given integers n,k. Construct a grid A with size n × n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of all elements in the grid is exactly k. In other words, the number of 1 in the grid is equal to k.

Let's define:

  * A_{i,j} as the integer in the i-th row and the j-th column. 
  * R_i = A_{i,1}+A_{i,2}+...+A_{i,n} (for all 1 ≤ i ≤ n). 
  * C_j = A_{1,j}+A_{2,j}+...+A_{n,j} (for all 1 ≤ j ≤ n). 
  * In other words, R_i are row sums and C_j are column sums of the grid A. 
  * For the grid A let's define the value f(A) = (max(R)-min(R))^2 + (max(C)-min(C))^2 (here for an integer sequence X we define max(X) as the maximum value in X and min(X) as the minimum value in X). 



Find any grid A, which satisfies the following condition. Among such grids find any, for which the value f(A) is the minimum possible. Among such tables, you can find any.

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Next t lines contain descriptions of test cases.

For each test case the only line contains two integers n, k (1 ≤ n ≤ 300, 0 ≤ k ≤ n^2).

It is guaranteed that the sum of n^2 for all test cases does not exceed 10^5.

Output

For each test case, firstly print the minimum possible value of f(A) among all tables, for which the condition is satisfied.

After that, print n lines contain n characters each. The j-th character in the i-th line should be equal to A_{i,j}.

If there are multiple answers you can print any.

Example

Input


4
2 2
3 8
1 0
4 16


Output


0
10
01
2
111
111
101
0
0
0
1111
1111
1111
1111

Note

In the first test case, the sum of all elements in the grid is equal to 2, so the condition is satisfied. R_1 = 1, R_2 = 1 and C_1 = 1, C_2 = 1. Then, f(A) = (1-1)^2 + (1-1)^2 = 0, which is the minimum possible value of f(A).

In the second test case, the sum of all elements in the grid is equal to 8, so the condition is satisfied. R_1 = 3, R_2 = 3, R_3 = 2 and C_1 = 3, C_2 = 2, C_3 = 3. Then, f(A) = (3-2)^2 + (3-2)^2 = 2. It can be proven, that it is the minimum possible value of f(A).

Solution (in JAVA):

Solution:
	import java.io.*;
	import java.util.*;
	import java.math.*;
	
	 
	 public class Main	{
	   static class Pair implements Comparable<Pair>{
	   int a;
	   int b;
	   public Pair(){}
	   public Pair(int x,int y){a=x;b=y;}
	   public int compareTo(Pair p){
		 return Integer.compare(a, p.a);
	   }
	//	   long a,b;
	//	   public Pair(long x,long y){a=x;b=y;}
	//	   public int compareTo(Pair p){
	//			 return Long.compare(a, p.a);
	//	   }
	//	  
	//	@Override
	//	public int hashCode() {
	//		final int prime = 31;
	//		int result = 1;
	//		result = prime * result + a;
	//		result = prime * result + b;
	//	//	out.println("hashcode = "+result);
	//		return result;
	//	}
	//	@Override
	//	public boolean equals(Object obj) {
	//		Pair cur = (Pair)obj;
	//		if((a==cur.a && b==cur.b) || (a==cur.b && b==cur.a))return true;
	//		return false;
	//	}
	 }
	   static class ArrayUtils {
		public static Integer[] generateOrder(int size) {
			Integer[] order = new Integer[size];
			for (int i = 0; i < size; i++)
				order[i] = i;
			return order;
		}
	 
		public static Integer[] order(int size, Comparator<Integer> comparator) {
			Integer[] order = generateOrder(size);
			Arrays.sort(order, comparator);
			return order;
		}
	 
			}
	   static class cell implements Comparable<cell>{
		   int a,b;
		   long dis;
		   public cell(int x,int y,long z) {a=x;b=y;dis=z;}
		   public int compareTo(cell c) {
			   return Long.compare(dis,c.dis);
		   }
	   }
	static class TrieNode{
		TrieNode left;
		TrieNode right;
		int op;
		int data;
		public TrieNode() {}
	}
	  public static int gcd(int a,int b)
	  {
	    if(a<b)
	
	      return gcd(b,a);
	    if(b==0)
	      return a;
	    return gcd(b,a%b);
	    
	  }
	  static int lcm(int a,int b) {
		  return  a*b / gcd(a,b);
	  }
	  //static long ans = 0;
	  static long mod = (long)(1e9+7); //998244353;//
	   
	    public static void main(String[] args) throws Exception {
	       new Thread(null, null, "Anshum Gupta", 99999999) {
	            public void run() {
	                try {
	                    solve();
	                } catch(Exception e) {
	                    e.printStackTrace();
	                    System.exit(1);
	                }
	            }
	        }.start();
	    }
	
	static long pow(long x,long y){
	    if(y == 0)return 1;
	    if(y==1)return x;
	    long a = pow(x,y/2);
	    a = (a*a)%mod;
	    if(y%2==0){
	        return a;
	    }
	    return (a*x)%mod;
	}
	
	static long mxx;
	static int mxN = (int)(2e6+5);
	static long[]fact,inv_fact;
	static long my_inv(long a) {
		return pow(a,mod-2);
	}
	static long bin(int a,int b) {
		if(a < b || a<0 || b<0)return 0;
	    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
	}
		static ArrayList<ArrayList<Integer>>adj;
		static boolean[]vis;
	static void make_facts() {
	  fact=new long[mxN];
	  inv_fact = new long[mxN];
	  fact[0]=inv_fact[0]=1L;
	  for(int i=1;i<mxN;i++) {
		   fact[i] = (i*fact[i-1])%mod;
		   inv_fact[i] = my_inv(fact[i]);
	  }
	}
	
	 public static void solve() throws Exception {
	   // solve the problem here
	   MyScanner s = new MyScanner();
	        out = new PrintWriter(new BufferedOutputStream(System.out), true);
	        int tc = s.nextInt();
	        mxx = (long)(1e18+5);
	//	        make_facts(); 
	//	        int mod = (int)1e9+7;
	        while(tc-->0){
	        	int n = s.nextInt();
	        	int k = s.nextInt();
	        	
	        	int[][]ans = new int[n][n];
	        	
	        	for(int i=0;i<n;i++) { // starting
	        		int j = i;
	        		int l = 0;
	        		int cnt = 0;
	        		if(k == 0)break;
	        		while(cnt < n) {
	        			ans[l][j] = 1;
	        			j = (j + 1) % n;
	        			l = (l + 1) % n;
	        			cnt++;
	        			k--;
	        			if(k == 0)break;
	        		}
	        		if(k == 0)break;
	        	}
	        	int minr = n+1, maxr = 0, minc = n+1, maxc = 0;
	        	for(int i=0;i<n;i++) {
	        		int sum = 0;
	        		for(int j=0;j<n;j++) {
	        			sum += ans[i][j];
	        		}
	        		minr = Math.min(minr, sum);
	        		maxr = Math.max(maxr, sum);
	        	}
	        	for(int i=0;i<n;i++) {
	        		int sum = 0;
	        		for(int j=0;j<n;j++) {
	        			sum += ans[j][i];
	        		}
	        		minc = Math.min(minc, sum);
	        		maxc = Math.max(maxc, sum);
	        	}
	        	int f = (maxr - minr) * (maxr - minr) + (maxc - minc) * (maxc - minc);
	        	out.println(f);
	        	for(int i=0;i<n;i++) {
	        		for(int j=0;j<n;j++) {
	        			out.print(ans[i][j]);
	        		}out.println();
	        	}
	        }
	        	
	           
	        out.flush();
	}
	 
	     
	 
	 
	 
	    //-----------PrintWriter for faster output---------------------------------
	    public static PrintWriter out;
	 
	    //-----------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;
	        }
	    }
	    //--------------------------------------------------------
	}