import java.util.Arrays;
import java.util.Scanner;
import java.math.BigInteger;
public class Pb {

	public static void main(String[] args) {
		Scanner x=new Scanner(System.in);
		int test=x.nextInt();

		while(test-->0) {

			BigInteger n = x.nextBigInteger();
			BigInteger i = new BigInteger("10");
			BigInteger z = new BigInteger("1");
			int count=0;

		while(true) {
			n=n.divide(i);
			  int c = n.compareTo(z);
		if(c!=0&&c!=1)
			break;
		count++;
		}

	System.out.println(count+1);
	}
}

}


import java.util.Scanner;

public class StrangeFunctions {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            String n = sc.next();
            System.out.println(n.length());

        }
        sc.close();
    }
}


import java.util.*;
import java.math.*;
public class Test{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
           BigInteger n=sc.nextBigInteger();
            System.out.println(Math.floor(Math.log10(n) + 1));
        }
    }
}


import java.util.*;
import java.math.*;
public class Test{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
           BigInteger n=sc.nextBigInteger();
            System.out.println(n.toString().length());
        }
    }
}


import java.util.*;
public class Test{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
           BigInteger n=sc.nextBigInteger();
            System.out.println(Math.floor(Math.log10(n) + 1));
        }
    }
}


import java.util.*;
public class Test{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            long n=sc.nextLong();
            System.out.println(Math.floor(Math.log10(n) + 1));
        }
    }
}


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();
               long c=0;
               if(!s.isEmpty())
               {
               long n = Long.parseLong(s);

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }
}


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();
               if(s!="")
               {
               long n = Long.parseLong(s);
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }
               }

               System.out.println(c);
          }
     }
}


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          sc.nextLine();
          while(t-- !=0)
          {

               BigInteger n = new BigInteger(sc.nextLine());

               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               long n =sc.nextLong();
               long c=0, f=0;

                    // if(i==1)
                    // {
                    //      c++;
                    //      i=i+9;
                    //      continue;
                    // }

                    // if(i== Math.pow(10,f))
                    // {
                    //      c++;
                    // }
                    // f++;
                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
          }
     }
}


import java.util.*;
 import java.math.BigInteger;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger()<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               long n =sc.nextLong();
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
          }
     }
}


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();

               long n = Long.parseLong(s);
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
          }
     }
}


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               long n =sc.nextLong();
               long c=0, f=0;
               for(long i=1 ;i<=n ; )
               {
                    if(i==1)
                    {
                         c++;
                         i=i+9;
                         continue;
                    }

                    if(i== Math.pow(10,f))
                    {
                         c++;
                    }
                    f++;

                    i= i+10;
               }
               System.out.println(c);
          }
     }
}


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();
               if(!s.isEmpty())
               BigInteger n = new BigInteger(s);
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }
}


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {

               BigInteger n = new BigInteger(sc.nextLine());
               if(n>0)
               {
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }
          }

          }
     }


import java.util.*;
 import java.math.BigInteger;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();
               s.nextLine();
               long n = Long.parseLong(s);
               long c=0;

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
          }
     }
}


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          sc.nextLine();
          while(t-- !=0)
          {
               String s = sc.nextLine();

               if(!s.isEmpty())
               BigInteger n = new BigInteger(sc.nextLine());

               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               BigInteger n = new BigInteger(sc.nextLine());
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger()<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }


import java.util.*;

public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s = sc.nextLine();
               long c=0;
               if(s!="")
               {
               long n = Long.parseLong(s);

                    long i=0;
                    while(Math.pow(10,i)<=n)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }

          }
     }
}


import java.util.*;
 import java.math.*;
public class Main{
     public static void main(String args[])
     {
          Scanner sc= new Scanner(System.in);
          int t= sc.nextInt();
          while(t-- !=0)
          {
               String s =

               BigInteger n = new BigInteger(sc.nextLine());
               if(n>0)
               {
               long c=0;

                    long i=0;

                    while(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger().compareTo(n)<=0)
                    {
                         i++;
                         c++;
                    }

               System.out.println(c);
               }
          }

          }
     }


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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
			Scanner sc = new Scanner(System.in);

		int t = sc.nextInt();

		while (t > 0) {

			String str = sc.next();

			System.out.println(str.length());

			t--;
		}
		sc.close();
	}
}


import java.util.*;
import java.util.regex.*;
public class Main
{

	public static void main(String[] args) {
	    int t;
	Scanner s=new Scanner(System.in);
	t=s.nextInt();
	while(t-->0)
	{
	String str=s.next();
	long length = str.length();
	String reverse = "";
    for (long i = length - 1 ; i >= 0 ; i--)
      reverse = reverse +str.charAt(i);
		removeLeadingZeros(reverse);

	}
	}
	public static void removeLeadingZeros(String reverse)
    {
        String regex = "^0+(?!$)";
        reverse = reverse.replaceAll(regex, "");
        System.out.println(reverse.length());
    }
}


import java.util.*;
import java.util.regex.*;
public class Main
{

	public static void main(String[] args) {
	    int t;
	Scanner s=new Scanner(System.in);
	t=s.nextInt();
	while(t-->0)
	{
	String str=s.next();
	long length = str.length();
	String reverse = "";
    for (long i = (int) (length - 1) ; i >= 0 ; i--)
      reverse = reverse +str.charAt((int) i);
		removeLeadingZeros(reverse);

	}
	}
	public static void removeLeadingZeros(String reverse)
    {
        String regex = "^0+(?!$)";
        reverse = reverse.replaceAll(regex, "");
        System.out.println(reverse.length());
    }
}


import java.util.*;
import java.util.regex.*;
public class Main
{

	public static void main(String[] args) {
	    int t;
	Scanner s=new Scanner(System.in);
	t=s.nextInt();
	while(t-->0)
	{
	String str=s.next();
	System.out.println(str.length());
	}}}


import java.util.*;
import java.util.regex.*;
public class Main
{

	public static void main(String[] args) {
	    int t;

	Scanner s=new Scanner(System.in);
	t=s.nextInt();
	while(t-->0)
	{
	String str=s.next();
	int length = str.length();
	String reverse = "";
    for (int i = length - 1 ; i >= 0 ; i--)
      reverse = reverse +str.charAt(i);
		removeLeadingZeros(reverse);

	}
	}
	public static void removeLeadingZeros(String reverse)
    {

        // Regex to remove leading
        // zeros from a string
        String regex = "^0+(?!$)";

        // Replaces the matched
        // value with given string
        reverse = reverse.replaceAll(regex, "");

        System.out.println(reverse.length());
    }
}


import java.util.*;
import java.util.regex.*;
public class Main
{

	public static void main(String[] args) {
	    int t;
	Scanner s=new Scanner(System.in);
	t=s.nextInt();
	while(t-->0)
	{
	String str=s.next();
	long length=0;
    char[] strCharArray=str.toCharArray();
    for(char c:strCharArray)
    {
     length++;
    }
	String reverse = "";
    for (long i = (length - 1) ; i >= 0 ; i--)
      reverse = reverse +str.charAt((int) i);
	removeLeadingZeros(reverse);

	}
	}
	public static void removeLeadingZeros(String reverse)
    {
        String regex = "^0+(?!$)";
        reverse = reverse.replaceAll(regex, "");
        long length=0;
        char[] strCharArray=reverse.toCharArray();
        for(char c:strCharArray)
        {
         length++;
        }
        //return length;
        System.out.println(reverse.length());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

//import da.FastReader;

public class CF_A {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            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;
        }
    }
	public static void main(String[] args) {
		OutputStream outputStream =System.out;
	    PrintWriter out =new PrintWriter(outputStream);
	FastReader s=new FastReader();
	int t=s.nextInt();
	while(t>0) {
String str=s.nextLine();
System.out.println(str.length());
		t--;
	}
out.close();
	}
	public static long[] merge_sort(long[] A, int start, int end) {
		if (end > start) {
			int mid = (end + start) / 2;
			long[] v = merge_sort(A, start, mid);
			long[] o = merge_sort(A, mid + 1, end);
			return (merge(v, o));
		} else {
			long[] y = new long[1];
			y[0] = A[start];
			return y;
		}
	}
	public static long[] merge(long a[], long b[]) {
//		int count=0;
		long[] temp = new long[a.length + b.length];
		int m = a.length;
		int n = b.length;
		int i = 0;
		int j = 0;
		int c = 0;
		while (i < m && j < n) {
			if (a[i] > b[j]) {
				temp[c++] = a[i++];

			} else {
				temp[c++] = b[j++];
			}
		}
		while (i < m) {
			temp[c++] = a[i++];
		}
		while (j < n) {
			temp[c++] = b[j++];
		}
		return temp;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

//import da.FastReader;

public class CF_A {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            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;
        }
    }
	public static void main(String[] args) {
		OutputStream outputStream =System.out;
	    PrintWriter out =new PrintWriter(outputStream);
	FastReader s=new FastReader();
	int t=s.nextInt();
	while(t>0) {
double n1=s.nextDouble();
//long n=(long) n1;
int count=0;
while(n1>0) {
	n1=Math.floor(n1/10);

	count++;
}
System.out.println(count);
		t--;
	}
out.close();
	}
	public static long[] merge_sort(long[] A, int start, int end) {
		if (end > start) {
			int mid = (end + start) / 2;
			long[] v = merge_sort(A, start, mid);
			long[] o = merge_sort(A, mid + 1, end);
			return (merge(v, o));
		} else {
			long[] y = new long[1];
			y[0] = A[start];
			return y;
		}
	}
	public static long[] merge(long a[], long b[]) {
//		int count=0;
		long[] temp = new long[a.length + b.length];
		int m = a.length;
		int n = b.length;
		int i = 0;
		int j = 0;
		int c = 0;
		while (i < m && j < n) {
			if (a[i] > b[j]) {
				temp[c++] = a[i++];

			} else {
				temp[c++] = b[j++];
			}
		}
		while (i < m) {
			temp[c++] = a[i++];
		}
		while (j < n) {
			temp[c++] = b[j++];
		}
		return temp;
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

//import da.FastReader;

public class CF_A {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            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;
        }
    }
	public static void main(String[] args) {
		OutputStream outputStream =System.out;
	    PrintWriter out =new PrintWriter(outputStream);
	FastReader s=new FastReader();
	int t=s.nextInt();
	while(t>0) {
String str=s.next();
System.out.println(str.length());
		t--;
	}
out.close();
	}
	public static long[] merge_sort(long[] A, int start, int end) {
		if (end > start) {
			int mid = (end + start) / 2;
			long[] v = merge_sort(A, start, mid);
			long[] o = merge_sort(A, mid + 1, end);
			return (merge(v, o));
		} else {
			long[] y = new long[1];
			y[0] = A[start];
			return y;
		}
	}
	public static long[] merge(long a[], long b[]) {
//		int count=0;
		long[] temp = new long[a.length + b.length];
		int m = a.length;
		int n = b.length;
		int i = 0;
		int j = 0;
		int c = 0;
		while (i < m && j < n) {
			if (a[i] > b[j]) {
				temp[c++] = a[i++];

			} else {
				temp[c++] = b[j++];
			}
		}
		while (i < m) {
			temp[c++] = a[i++];
		}
		while (j < n) {
			temp[c++] = b[j++];
		}
		return temp;
	}

}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int t=sc.nextInt();
      while(t--!=0)
      {
        String n=sc.next();
        solve(n);
      }
    }
    static void solve(String s)
    {
        System.out.println(s.length());
    }
}


import java.util.*;
import java.io.*;

public class TaskA {
    public void solve()
    {
        int t = Integer.parseInt(cin.nextLine());
        while (t --> 0)
        {
            String s = cin.nextLine();
            out.println(s.length());
        }
    }

    public static void main(String[] args) throws IOException {
        TaskA solver = new TaskA();
        solver.solve();
        solver.out.close();
    }

    Scanner cin = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
}


import java.io.BufferedReader;
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.math.BigInteger;
public class A334
{
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static void pn(Object o) {
		out.println(o);
		out.flush();

	}

	static void p(Object o) {
		out.print(o);
		out.flush();
	}

	static void pni(Object o) {
		out.println(o);
		System.out.flush();
	}

	static int I() throws IOException {
		return sc.nextInt();
	}

	static long L() throws IOException {
		return sc.nextLong();
	}

	static double D() throws IOException {
		return sc.nextDouble();
	}

	static String S() throws IOException {
		return sc.next();
	}

	static char C() throws IOException {
		return sc.next().charAt(0);
	}
	static int[] Ai(int n) throws IOException {
		int[] arr = new int[n];

		for (int i = 0; i < n; i++)
			arr[i] = I();

		return arr;
	}

	static String[] As(int n) throws IOException {
		String s[] = new String[n];

		for (int i = 0; i < n; i++)
			s[i] = S();

		return s;
	}

	static long[] Al(int n) throws IOException {
		long[] arr = new long[n];

		for (int i = 0; i < n; i++)
			arr[i] = L();

		return arr;
	}
	public static void process() throws IOException
	{
	      int x=I();long p=0;long q=0;long c=0;
	      for(int i=1;i<(x+10);i++)
	      {
	    	  if((i*(i+1))/2>x)
	    	  {
	    		  q=i;
	    		  p=(i*(i+1))/2;

	    		  break;
	    	  }
	    	  else
	    	if((i*(i+1))/2==x)
	    	{
	    		q=i;
	    		break;
	    	}
	      }
	      if(p>0)
	      {
	    	  long c1=0;c=p;boolean flag=false;long c2=0;
	    	  for(int i=1;i<x+10;i++)
	    	  {
	    		   c=c-(2*(1));
	    		  	c1++;
	    		  	c2=c2+(1
	    		  			);
		    	    if(c==x)
		    	    {
		    	    	flag=true;
		    	    	break;
		    	    }

	    	  }
	    	  if(flag)
	    	  {

	    		  pn(Math.min((q-c1+c2),(q+(p-x))));
	    	  }
	    	  else
	    	  pn(q+(p-x));
	      }
	      else
	      if(p==0)
	      {
	    	  pn(q);
	      }
	      }
	public static void main(String[] args) throws IOException {

		int t = I();
		while (t-- > 0)
			process();

	}
}


import java.io.BufferedReader;
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.math.BigInteger;
public class A334
{
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static void pn(Object o) {
		out.println(o);
		out.flush();

	}

	static void p(Object o) {
		out.print(o);
		out.flush();
	}

	static void pni(Object o) {
		out.println(o);
		System.out.flush();
	}

	static int I() throws IOException {
		return sc.nextInt();
	}

	static long L() throws IOException {
		return sc.nextLong();
	}

	static double D() throws IOException {
		return sc.nextDouble();
	}

	static String S() throws IOException {
		return sc.next();
	}

	static char C() throws IOException {
		return sc.next().charAt(0);
	}
	static int[] Ai(int n) throws IOException {
		int[] arr = new int[n];

		for (int i = 0; i < n; i++)
			arr[i] = I();

		return arr;
	}

	static String[] As(int n) throws IOException {
		String s[] = new String[n];

		for (int i = 0; i < n; i++)
			s[i] = S();

		return s;
	}

	static long[] Al(int n) throws IOException {
		long[] arr = new long[n];

		for (int i = 0; i < n; i++)
			arr[i] = L();

		return arr;
	}
	public static void process() throws IOException
	{
	   String s=S();
	   pn(s.length());
	}
	public static void main(String[] args) throws IOException {

		int t = I();
		while (t-- > 0)
			process();

	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
public class strange
{
    public static void main(String args[])throws Exception
    {
        try
        {
              Scanner sc=new Scanner(System.in);
              int t=sc.nextInt();
              while(t-->0)
              {
        String a=sc.next();
       System.out.println(a.length());
        }

    }
    catch(Exception e)
    {
        return;
    }
    }
}


import java.io.*;
import java.util.*l
import java.lang.*;
public class strange
{
    public static void main(String args[])throws Exception
    {
        try
        {
              Scanner sc=new Scanner(System.in);
              int t=sc.nextInt();
              while(t-->0)
              {
        String a=sc.next();
       System.out.println(a.length());
        }

    }
    catch(Exception e)
    {
        return;
    }
    }
}


import java.util.*;

public class Untitled {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t;
		String str = new String();
		t = sc.nextInt();
		for(int i=0;i<t;i++){
			str = sc.next();
			System.out.println(str.length());
		}
		sc.close();
	}
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0)System.out.println(sc.next().length());
    }
}


import java.util.*;

public class Main {
    /**
     * @param a long长整型 木棒的长度
     * @return int整型
     */

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(s.length());
        sc.close();
    }

}


import java.util.*;

public class Main {
    /**
     * @param a long长整型 木棒的长度
     * @return int整型
     */

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            String s = sc.next();
            System.out.println(s.length());
        }
        sc.close();
    }

}


import java.io;
import java.util.Scanner;

public class Example{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String testCases = br.readLine();
        int t = Integer.parseInt(testCases);
        while(t-- > 0){
            String number = br.readLine();
            System.out.println(number.length());
        }
    }
}


import java.io.*;
import java.util.Scanner;

public class Example{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String testCases = br.readLine();
        int t = Integer.parseInt(testCases);
        while(t-- > 0){
            String number = br.readLine();
            System.out.println(number.length());
        }
    }
}


import java.util.*;
import java.io.*;
public class Solution{

     public static void main(String []args){
            Scanner sc = new Scanner(System.in);

            int t = sc.nextInt();
            sc.nextLine();

            while(t > 0){

               String s = sc.nextLine();

                System.out.println(s.length());
                t--;
            }

     }

}


import java.util.*;
import java.io.*;
public class Solution{

     public static void main(String []args){
            Scanner sc = new Scanner(System.in);

            int t = sc.nextInt();

            while(t > 0){

               String s = sc.nextLine();

                System.out.println(s.length());
                t--;
            }

     }

}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-->0){
		    String n = scan.next();
		    if (n.charAt(n.length()-1) == '0') {
		        while(n.charAt(n.length()-1) != '0') {
		            n = n.substring(0,n.length()-1);
		            if (n.length()==0)
		                break;
		        }
		    }
		    System.out.println(n.length());
		}
	}
}


import java.io.*;
import java.util.*;

public class cfe99 {
    static PrintWriter out;
    static class FIO {
        BufferedReader in;
        StringTokenizer st;
        FIO() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        FIO(String name) throws IOException {
            in = new BufferedReader(new FileReader(name + ".in"));
            out = new PrintWriter(new FileWriter(name + ".out"));
        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int ni() {
            return Integer.parseInt(next());
        }
        long nl() {
            return Long.parseLong(next());
        }
        double nd() {
            return Double.parseDouble(next());
        }
    }
    static FIO in;
    public static void main (String[] args) throws IOException {
        in = new FIO();
        int tc = in.ni();
        while (tc-- > 0)
            new solver();
        out.close();
    }
    static class solver {
        solver() {
            String s = in.next();
            out.println(s.length());
        }
    }
}


import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int t = input.nextInt();
        int count = 0;
        while(t > 0) {
            BigInteger n = input.nextBigInteger();
            BigInteger division = new BigInteger("10");
            BigInteger zero = new BigInteger("0");
            do {
                n = n.divide(division);
                count++;
            } while(n.compareTo(zero) != 0);

            System.out.println(count);
            count = 0;
            t--;
        }
    }
}


import java.math.BigInteger;
import java.util.*;

public class test {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		System.out.println(s.length());

}
}


import java.math.BigInteger;
import java.util.*;

public class test {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0) {
			String s=sc.next();
			System.out.println(s.length());

		}

}
}


import javax.swing.*;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class HackerEarth {

    public static PrintWriter out = new PrintWriter(System.out);
    public static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = ni();

        while (t-- > 0) {

            BigInteger bi = sc.nextBigInteger();
            System.out.println(bi.toString().length());
        }
    }

    private static int ni() {
        return in.nextInt();
    }

    private static int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private static long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private static long nl() {
        return in.nextLong();
    }

    private float nf() {
        return in.nextFloat();
    }

    private static double nd() {
        return in.nextDouble();
    }

    private static String ns() {
        return in.next();
    }
}


import javax.swing.*;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class HackerEarth {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        while (t-- > 0) {

            BigInteger bi = sc.nextBigInteger();
            System.out.println(bi.toString().length());
        }
    }
}


import java.io.*;

import java.util.*;

/*
 */
public class A {
	static FastReader sc=null;

	public static void main(String[] args) {
		sc=new FastReader();
		int t=sc.nextInt();
		while(t-->0) {
			char line[]=sc.next().toCharArray();
			System.out.println(line.length);
		}

	}

	static int[] reverse(int a[]) {
		ArrayList<Integer> al=new ArrayList<>();
		for(int i:a)al.add(i);
		Collections.sort(al,Collections.reverseOrder());
		for(int i=0;i<a.length;i++)a[i]=al.get(i);
		return a;
	}

	static void print(long a[]) {
		for(long e:a) {
			System.out.print(e+" ");
		}
		System.out.println();
	}

	static void print(int a[]) {
		for(int e:a) {
			System.out.print(e+" ");
		}
		System.out.println();
	}

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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;
        }
        int[] readArray(int n) {
    		int a[]=new int [n];
    		for(int i=0;i<n;i++) {
    			a[i]=sc.nextInt();
    		}
    		return a;
    	}
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class Rextester
{
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-->0){

            BigInteger n = new BigInteger(in.next());
        //BigInteger n = in.nextBigInteger();
        //int ans = (int)Math.floor(Math.log10(n) + 1);
            int ans = n.toString().length();
        System.out.println(ans);
        }

    }
}


import java.util.*;
public class Satya
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int t=s.nextInt();
        s.nextLine();
        while(t-->0)
        {
            String str=s.nextLine();
            System.out.println(str.length());

        }
    }
}


import java.util.*;
public class Satya
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int t=s.nextInt();
        while(t-->0)
        {
            int n=s.nextInt();
            String str=String.valueOf(n);
            System.out.println(str.length());
        }
    }
}


import java.util.*;
public class Satya
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int t=s.nextInt();
        while(t-->0)
        {
            String str=s.nextLine();
            System.out.println(str.length());

        }
    }
}


#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long

#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
//#define endl                           '\n'

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

/*ll prime[1000006];
void fun()
{
  for(ll i=2;i<=1000000;i++)
  {
    if(prime[i]==0)
    {
      for(ll j=i+i;j<=1000000;j+=i)
      {
        if(prime[j]==0)
        prime[j]=i;
      }
    }
  }
}*/
/*const int MAXR = 1000005;

ll cubic_root(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}*/

/*ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}*/
/*bool checkprime(ll n)
{
  ll i;
  if(n<=3)
    return true;

  if(n%2==0 || n%3==0)
    return false;

  for(i=5;i*i<=n;i+=6)
  {
    if(n%i==0 || n%(i+2)==0)
      return false;
  }

  return true;

}*/

/*ll check(ll n,ll b) //to calculate NcR
{
  ll i,p=1,P=1,ans=1;
  if(n<3)
    return 0;
  for(i=1;i<=b;i++)
  {
    ans=ans*(n-i+1)/i;
  }

  return ans;
}*/

/*const int N = 1e5+7;

ll prime[N];
//ll n;
vector<int>p;
vector<int>ans;

void sv()
{
  for(int i=1;i<N;i++)
    prime[i]=1;

  for(int i=2;i*i<=N;i++)
  {
    if(prime[i])
    {
      for(int j=i*i;j<N;j+=i)
      {
        prime[j]=0;
      }
    }
  }

  for(int i=2;i<N;i++)
  {
    if(prime[i])
      p.pb(i);
  }
  return ;
}
/*
void solve()
{
  int n;
  cin>>n;
  sv();
  for(auto i:p)
  {
    if(i>n)
      break;

    for(int j=1;pow(i,j)<=n;j++)
      ans.pb(pow(i,j));
  }

  cout<<ans.size()<<endl;
  for(auto i:ans)
    cout<<i<<" ";
  cout<<endl;
  //cout<<"ef"<<endl;
return ;
}*/

int main()
{
  ll n,k,i,j;
  cin>>n>>k;
  ll a[n][n];
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
      a[i][j]=0;
  }

 // cout<<"sf"<<endl;
    if(k<=n)
    {
     // cout<<"df"<<endl;
      for(i=0;i<k;i++)
        a[i][i]=1;

      for(i=0;i<n;i++)
      {
        for(j=0;j<n;j++)
          cout<<a[i][j]<<" ";

        cout<<endl;

      }
      return 0;
    }

  bool ok=true;

  for(i=0;i<n;i++)
    a[i][i]=1;

  k-=n;
  for(i=0;i<n;i++)
  {
    for(j=0;j<i;j++)
    {
      if(i!=j){
        if(k<=0)
        {
          ok=false;
          break;
        }
        a[i][j]=1;
        a[j][i]=1;

    }}
    if(!ok)
      break;
  }

  if(k>0)
    cout<<-1<<endl;
  else
  {
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        cout<<a[i][j]<<" ";
      cout<<endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long

#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
//#define endl                           '\n'

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

/*ll prime[1000006];
void fun()
{
  for(ll i=2;i<=1000000;i++)
  {
    if(prime[i]==0)
    {
      for(ll j=i+i;j<=1000000;j+=i)
      {
        if(prime[j]==0)
        prime[j]=i;
      }
    }
  }
}*/
/*const int MAXR = 1000005;

ll cubic_root(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}*/

/*ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}*/
/*bool checkprime(ll n)
{
  ll i;
  if(n<=3)
    return true;

  if(n%2==0 || n%3==0)
    return false;

  for(i=5;i*i<=n;i+=6)
  {
    if(n%i==0 || n%(i+2)==0)
      return false;
  }

  return true;

}*/

/*ll check(ll n,ll b) //to calculate NcR
{
  ll i,p=1,P=1,ans=1;
  if(n<3)
    return 0;
  for(i=1;i<=b;i++)
  {
    ans=ans*(n-i+1)/i;
  }

  return ans;
}*/

/*const int N = 1e5+7;

ll prime[N];
//ll n;
vector<int>p;
vector<int>ans;

void sv()
{
  for(int i=1;i<N;i++)
    prime[i]=1;

  for(int i=2;i*i<=N;i++)
  {
    if(prime[i])
    {
      for(int j=i*i;j<N;j+=i)
      {
        prime[j]=0;
      }
    }
  }

  for(int i=2;i<N;i++)
  {
    if(prime[i])
      p.pb(i);
  }
  return ;
}
/*
void solve()
{
  int n;
  cin>>n;
  sv();
  for(auto i:p)
  {
    if(i>n)
      break;

    for(int j=1;pow(i,j)<=n;j++)
      ans.pb(pow(i,j));
  }

  cout<<ans.size()<<endl;
  for(auto i:ans)
    cout<<i<<" ";
  cout<<endl;
  //cout<<"ef"<<endl;
return ;
}*/

int main()
{
  ll n,k,i,j;
  cin>>n>>k;
  ll a[n][n];
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
      a[i][j]=0;
  }

 // cout<<"sf"<<endl;
    if(k<=n)
    {
     // cout<<"df"<<endl;
      for(i=0;i<k;i++)
        a[i][i]=1;

      for(i=0;i<n;i++)
      {
        for(j=0;j<n;j++)
          cout<<a[i][j]<<" ";

        cout<<endl;

      }
      return 0;
    }

  bool ok=true;

  for(i=0;i<n;i++)
    a[i][i]=1;

  k-=n;
  for(i=0;i<n;i++)
  {
    for(j=0;j<i;j++)
    {
      if(i!=j){
        if(k<=0)
        {
          ok=false;
          break;
        }
        a[i][j]=1;
        if(k<=0)
        {
          ok=false;
          break;
        }
        a[j][i]=1;
        k-=2;

    }}
    if(!ok)
      break;
  }

  if(k>0)
    cout<<-1<<endl;
  else
  {
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        cout<<a[i][j]<<" ";
      cout<<endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long

#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
//#define endl                           '\n'

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

/*ll prime[1000006];
void fun()
{
  for(ll i=2;i<=1000000;i++)
  {
    if(prime[i]==0)
    {
      for(ll j=i+i;j<=1000000;j+=i)
      {
        if(prime[j]==0)
        prime[j]=i;
      }
    }
  }
}*/
/*const int MAXR = 1000005;

ll cubic_root(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}*/

/*ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}*/
/*bool checkprime(ll n)
{
  ll i;
  if(n<=3)
    return true;

  if(n%2==0 || n%3==0)
    return false;

  for(i=5;i*i<=n;i+=6)
  {
    if(n%i==0 || n%(i+2)==0)
      return false;
  }

  return true;

}*/

/*ll check(ll n,ll b) //to calculate NcR
{
  ll i,p=1,P=1,ans=1;
  if(n<3)
    return 0;
  for(i=1;i<=b;i++)
  {
    ans=ans*(n-i+1)/i;
  }

  return ans;
}*/

/*const int N = 1e5+7;

ll prime[N];
//ll n;
vector<int>p;
vector<int>ans;

void sv()
{
  for(int i=1;i<N;i++)
    prime[i]=1;

  for(int i=2;i*i<=N;i++)
  {
    if(prime[i])
    {
      for(int j=i*i;j<N;j+=i)
      {
        prime[j]=0;
      }
    }
  }

  for(int i=2;i<N;i++)
  {
    if(prime[i])
      p.pb(i);
  }
  return ;
}
/*
void solve()
{
  int n;
  cin>>n;
  sv();
  for(auto i:p)
  {
    if(i>n)
      break;

    for(int j=1;pow(i,j)<=n;j++)
      ans.pb(pow(i,j));
  }

  cout<<ans.size()<<endl;
  for(auto i:ans)
    cout<<i<<" ";
  cout<<endl;
  //cout<<"ef"<<endl;
return ;
}*/

int main()
{
	ll n,k,i,j;
	cin>>n>>k;
	ll a[n][n];

	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			a[i][j]=0;
	}
	if(k>n*n)
	{
		cout<<-1<<endl;
		return 0;
	}

	if(k<=n)
	{
		for(i=0;i<k;i++)
			a[i][i]=1;

		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
				cout<<a[i][j]<<" ";

			cout<<endl;
		}

		return 0;
	}
	bool ok=true;
	for(i=0;i<n;i++)
		a[i][i]=1;

	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			if(k<2)
			{
				ok=false;
				break;
			}
			a[i][j]=1;
			a[j][i]=1;
			k-=2;
		}
		if(!ok)
			break;
	}

	if(k!=0)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			cout<<a[i][j]<<" ";
		cout<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long

#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
//#define endl                           '\n'

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

/*ll prime[1000006];
void fun()
{
  for(ll i=2;i<=1000000;i++)
  {
    if(prime[i]==0)
    {
      for(ll j=i+i;j<=1000000;j+=i)
      {
        if(prime[j]==0)
        prime[j]=i;
      }
    }
  }
}*/
/*const int MAXR = 1000005;

ll cubic_root(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}*/

/*ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}*/
/*bool checkprime(ll n)
{
  ll i;
  if(n<=3)
    return true;

  if(n%2==0 || n%3==0)
    return false;

  for(i=5;i*i<=n;i+=6)
  {
    if(n%i==0 || n%(i+2)==0)
      return false;
  }

  return true;

}*/

/*ll check(ll n,ll b) //to calculate NcR
{
  ll i,p=1,P=1,ans=1;
  if(n<3)
    return 0;
  for(i=1;i<=b;i++)
  {
    ans=ans*(n-i+1)/i;
  }

  return ans;
}*/

/*const int N = 1e5+7;

ll prime[N];
//ll n;
vector<int>p;
vector<int>ans;

void sv()
{
  for(int i=1;i<N;i++)
    prime[i]=1;

  for(int i=2;i*i<=N;i++)
  {
    if(prime[i])
    {
      for(int j=i*i;j<N;j+=i)
      {
        prime[j]=0;
      }
    }
  }

  for(int i=2;i<N;i++)
  {
    if(prime[i])
      p.pb(i);
  }
  return ;
}
/*
void solve()
{
  int n;
  cin>>n;
  sv();
  for(auto i:p)
  {
    if(i>n)
      break;

    for(int j=1;pow(i,j)<=n;j++)
      ans.pb(pow(i,j));
  }

  cout<<ans.size()<<endl;
  for(auto i:ans)
    cout<<i<<" ";
  cout<<endl;
  //cout<<"ef"<<endl;
return ;
}*/

int main()
{
  ll n,k,i,j;
  cin>>n>>k;
  ll a[n][n];
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
      a[i][j]=0;
  }

 // cout<<"sf"<<endl;
    if(k<=n)
    {
     // cout<<"df"<<endl;
      for(i=0;i<k;i++)
        a[i][i]=1;

      for(i=0;i<n;i++)
      {
        for(j=0;j<n;j++)
          cout<<a[i][j]<<" ";

        cout<<endl;

      }
      return 0;
    }

  bool ok=true;

  for(i=0;i<n;i++)
    a[i][i]=1;

  k-=n;
  for(i=0;i<n;i++)
  {
    for(j=0;j<i;j++)
    {
      if(i!=j){
        if(k<2)
        {
          ok=false;
          break;
        }
        a[i][j]=1;
        a[j][i]=1;
        k-=2;

    }}
    if(!ok)
      break;
  }

  if(k>0)
    cout<<-1<<endl;
  else
  {
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        cout<<a[i][j]<<" ";
      cout<<endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#define hell                         1000000007
#define M                            1000000007
#define Maxi                      10000000000000000
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long

#define vll                          vector<ll>
#define vi                           vector<long long>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
//#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
//#define endl                           '\n'

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

/*ll prime[1000006];
void fun()
{
  for(ll i=2;i<=1000000;i++)
  {
    if(prime[i]==0)
    {
      for(ll j=i+i;j<=1000000;j+=i)
      {
        if(prime[j]==0)
        prime[j]=i;
      }
    }
  }
}*/
/*const int MAXR = 1000005;

ll cubic_root(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}*/

/*ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}*/
/*bool checkprime(ll n)
{
  ll i;
  if(n<=3)
    return true;

  if(n%2==0 || n%3==0)
    return false;

  for(i=5;i*i<=n;i+=6)
  {
    if(n%i==0 || n%(i+2)==0)
      return false;
  }

  return true;

}*/

/*ll check(ll n,ll b) //to calculate NcR
{
  ll i,p=1,P=1,ans=1;
  if(n<3)
    return 0;
  for(i=1;i<=b;i++)
  {
    ans=ans*(n-i+1)/i;
  }

  return ans;
}*/

/*const int N = 1e5+7;

ll prime[N];
//ll n;
vector<int>p;
vector<int>ans;

void sv()
{
  for(int i=1;i<N;i++)
    prime[i]=1;

  for(int i=2;i*i<=N;i++)
  {
    if(prime[i])
    {
      for(int j=i*i;j<N;j+=i)
      {
        prime[j]=0;
      }
    }
  }

  for(int i=2;i<N;i++)
  {
    if(prime[i])
      p.pb(i);
  }
  return ;
}
/*
void solve()
{
  int n;
  cin>>n;
  sv();
  for(auto i:p)
  {
    if(i>n)
      break;

    for(int j=1;pow(i,j)<=n;j++)
      ans.pb(pow(i,j));
  }

  cout<<ans.size()<<endl;
  for(auto i:ans)
    cout<<i<<" ";
  cout<<endl;
  //cout<<"ef"<<endl;
return ;
}*/

int main()
{
  ll n,k,i,j;
  cin>>n>>k;

  ll a[n][n];

  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<n;j++)
    {
      a[i][j]=0;
    }
  }

 // cout<<"sf"<<endl;
    if(k<=n)
    {
     // cout<<"df"<<endl;
      for(i=0;i<k;i++)
        a[i][i]=1;

      for(i=0;i<n;i++)
      {
        for(j=0;j<n;j++)
          cout<<a[i][j]<<" ";

        cout<<endl;

      }
      return 0;
    }

  bool ok=true;

  for(i=0;i<n;i++)
    a[i][i]=1;

  k-=n;
  for(i=0;i<n;i++)
  {
    if(k==0)
      break;
    for(j=0;j<=i;j++)
    {
      if(i!=j){
        if(k<2)
        {
          ok=false;
          break;
        }
        a[i][j]=1;
        a[j][i]=1;
        k-=2;
        if(k==0)
          break;

    }
  }
    if(!ok)
      break;
  }

  if(k>0)
    cout<<-1<<endl;
  else
  {
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        cout<<a[i][j]<<" ";
      cout<<endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    ll root=sqrt(k);
    ll a[n+9][n+9];
    if(n*n==k)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<1;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    else if(n*n==k+1)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                if(i== n-1 && j==n-1)
                    cout<<0;
                else
                    cout<<1;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    else if(k-(root*root)<=n-root)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                if(i<root && j<root)
                {
                    cout<<1;
                    k--;
                }
                else if(k>0 && i==j)
                {
                    cout<<1;
                    k--;
                }
                else
                    cout<<0;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
    else
        cout<<-1;
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
ll a[200][200];
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    if(n*n>=k)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=i; j<n && k>0; j++)
            {
                if(i==j)
                {
                    a[i][j]=1;
                    k--;
                }
                else if(k>=2)
                {
                    a[i][j]=1;
                    a[j][i]=1;
                    k-=2;
                }
            }
        }
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<a[i][j];
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
    else
        cout<<-1;
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    ll a[n+9][n+9];
    if(n*n==k)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<1;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            if(i==j && k>0)
            {
                a[i][j]=1;
                k--;
            }
            else
            {
                a[i][j]=0;
            }
        }
    }
    if(k!=0)
        cout<<-1;
    else
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<a[i][j];
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    ll a[n+9][n+9]={0};
    if(n*n>=k)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=i; j<n && k>0; j++)
            {
                if(i==j)
                {
                    a[i][j]=1;
                    k--;
                }
                else if(k>=2)
                {
                    a[i][j]=1;
                    a[j][i]=1;
                    k-=2;
                }
            }
        }
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<a[i][j];
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
    else
        cout<<-1;
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    ll root=sqrt(k);
    ll a[n+9][n+9];
    if(n*n==k)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<1;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    else if(k-(root*root)<=n-root)
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                if(i<root && j<root)
                {
                    cout<<1;
                    k--;
                }
                else if(k>0 && i==j)
                {
                    cout<<1;
                    k--;
                }
                else
                    cout<<0;
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
    else
        cout<<-1;
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
set<ll>se;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
vector<ll>v;
vector<ll>index;
vector<ll>:: iterator l;
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    ll a[n+9][n+9];
    ll c=0;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<n; j++)
        {
            if(i==j && k>0)
            {
                a[i][j]=1;
                k--;
            }
            else
            {
                a[i][j]=0;
            }
        }
    }
    if(k!=0)
        cout<<-1;
    else
    {
        for(ll i=0; i<n; i++)
        {
            for(ll j=0; j<n; j++)
            {
                cout<<a[i][j];
                if(j!=n-1)
                    cout<<" ";
            }
            cout<<endl;
        }
    }
}


#include<bits/stdc++.h>
#define ll long long
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
//vector <ll> G[30000];
//vector<ll>wt[]
//bool vis[30000];
//ll dis[30000];
//map<string,ll>mp;
set<ll>se;
//void dfs(ll a)
//{
//    vis[a]=1;
//    dis[a]=0;
//    for(ll i=0; i<G[a].size(); i++)
//    {
//        ll b=G[a][i];
//        if(vis[b]==0)
//            dfs(b);
//    }
//}
vector<ll>v;
vector<ll>index;
vector<ll>:: iterator l;
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    fast;
    ll n,k;
    cin>>n>>k;
    if(n==1 && k==1)
        cout<<1;
    else if(n==1 && k==0)
        cout<<0;
    if(k>=n)
        cout<<-1;
    else
    {
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {
                if(i==j && i!=n-1)
                    cout<<1;
                else
                    cout<<0;
                if(j==n-1)
                    cout<<endl;
                else
                    cout<<" ";
            }
        }
    }

}


#include <iostream>
using namespace std;

int n,a[101][101],k;

int main()
{
    int i,j;
    cin>>n>>k;
    if(k<=n)
        goto rezolva;
    else
    if(n%2==0&&k%2==1)
        cout<<-1<<"\n";
    else if(n%2==1&&k%2==0)
        cout<<-1<<"\n";
    else if(k>n*n)
        cout<<-1<<"\n";
    else if(k==n*n)
    {
        for(i=1; i<=n; ++i)
        {
            for(j=1; j<=n; ++j)
                cout<<1<<" ";
            cout<<"\n";
        }
    }
    else
    {
        int ii,jj;
        rezolva:
        //Prima jumatate
        for(i=1; i<=n; ++i)
            if(i%2==1)
            {
                ii=i;
                for(j=1; j<=i/2+1; ++j)
                {
                    a[ii][j]=1;
                    a[j][ii]=1;
                    if(ii==j)
                        --k;
                    else
                        k-=2;
                    --ii;
                    if(k==0)
                        goto proces;
                }
            }
            else
            {
                ii=i;
                for(j=1; j<=i/2; ++j)
                {
                    a[ii][j]=1;
                    a[j][ii]=1;
                    k-=2;
                    --ii;
                    if(k==0)
                        goto proces;
                }
            }

        //A doua jumatate

        for(j=2; j<=n; ++j)
        {
            jj=n;
            for(i=j; i<=(n+j)/2; ++i)
            {
                a[i][jj]=1;
                a[jj][i]=1;
                if(jj==i)
                    --k;
                else
                    k-=2;
                --jj;
                if(k==0)
                    goto proces;
            }
        }

        proces:
        for(i=1; i<=n; ++i)
        {
            for(j=1; j<=n; ++j)
                cout<<a[i][j]<<" ";
            cout<<"\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -= 2;
                if(j == i) m++;
            }
            if(m == 1) {
                m--;
                a[i + 1][i + 1] = 1;
                break;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    if(m <= n) {
        rep(i , 1 , n) {
            rep(j , 1 , n) {
                if(i == j) {
                    m--;
                    a[i][j] = 1;
                }
                if(m == 0) break;
            }
            if(m == 0) break;
        }
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(m == 1) {
                m--;
                a[i][i] = 1;
                break;
            }
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -= 2;
                if(j == i) m++;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    if(m <= n) {
        rep(i , 1 , n) {
            rep(j , 1 , n) {
                if(i == j) {
                    m--;
                    a[i][j] = 1;
                }
                if(m == 0) break;
            }
            if(m == 0) break;
        }
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(m == 1) {
                m--;
                a[i + 1][i + 1] = 1;
                break;
            }
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -= 2;
                if(j == i) m++;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    if(m <= n) {
        rep(i , 1 , n) {
            rep(j , 1 , n) {
                if(i == j) {
                    m--;
                    a[i][j] = 1;
                }
                if(m == 0) break;
            }
            if(m == 0) break;
        }
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(i == j) {
                m--;
                a[i][j] = 1;
            }
        }
    }
    if(m % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -=2 ;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    if(m <= n) {
        rep(i , 1 , n) {
            rep(j , 1 , n) {
                if(i == j) {
                    m--;
                    a[i][j] = 1;
                }
                if(m == 0) break;
            }
            if(m == 0) break;
        }
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -= 2;
                if(j == i) m++;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
int n;
int m;
int a[123][123];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    cin >> n >> m;
    if(m > n * n) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 0) {
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    if(m <= n) {
        rep(i , 1 , n) {
            rep(j , 1 , n) {
                if(i == j) {
                    m--;
                    a[i][j] = 1;
                }
                if(m == 0) break;
            }
            if(m == 0) break;
        }
        rep(i , 1 , n) {
            rep(j , 1 , n) cout << a[i][j] << " ";
            cout << endl;
        }
        return 0;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) {
            if(a[i][j] != 1) {
                a[i][j] = 1;
                a[j][i] = 1;
                m -= 2;
                if(j == i) m++;
            }
            if(m == 1) {
                m--;
                a[i + 1][i + 1] = 1;
                break;
            }
            if(m == 0) break;
        }
        if(m == 0) break;
    }
    rep(i , 1 , n) {
        rep(j , 1 , n) cout << a[i][j] << " ";
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[101][101];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}
	if(k<n)
	{
		for(i=0;i<n;i++)
		{
		 for(j=0;j<n;j++)
		{
			if(i==j && k>0)
			cout<<"1 ", k--;
			else
			cout<<"0 ";
		}
		cout<<"\n";
	    }
	    return 0;
	}

	for(i=0;i<n;i++)
	b[i][i]=1;
	k-=n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(k>0)
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[105][105];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}

	for(i=0;i<n && k>0;i++)
	{
		b[i][i]=1;
		k--;
		for(j=i+1;j<n && k>1;j++)
		{
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[101][101];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}
	if(k<=n)
	{
		for(i=0;i<n;i++)
		{
		 for(j=0;j<n;j++)
		{
			if(i==j && k>0)
			cout<<"1 ", k--;
			else
			cout<<"0 ";
		}
		cout<<"\n";
	    }
	    return 0;
	}

	for(i=0;i<n;i++)
	b[i][i]=1;
	k-=n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(k>=2)
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[100][100];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[102][102];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}
	if(k<n)
	{
		for(i=0;i<n;i++)
		{
		 for(j=0;j<n;j++)
		{
			if(i==j && k>0)
			cout<<"1 ", k--;
			else
			cout<<"0 ";
		}
		cout<<"\n";
	    }
	    return 0;
	}

	for(i=0;i<n;i++)
	b[i][i]=1;
	k-=n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(k>0)
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}
	if(k<n)
	{
		for(i=0;i<n;i++)
		{
		 for(j=0;j<n;j++)
		{
			if(i==j && k>0)
			cout<<"1 ", k--;
			else
			cout<<"0 ";
		}
		cout<<"\n";
	    }
	    return 0;
	}

	for(i=0;i<n;i++)
	b[i][i]=1;
	k-=n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(k>0)
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[105][105];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	for(i=0;i<n && k>0;i++)
	{
		b[i][i]=1;
		k--;
		for(j=i+1;j<n && k>1;j++)
		{
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	if(k==0)
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
	else
	cout<<-1;
}


#include<bits/stdc++.h>

 using namespace std;
 typedef long long int ll;
 typedef unsigned long long int ull;
 int a[1000000]={0};
 int b[100][100];
 int main()
 {
 	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	if(k>n*n)
	{
		cout<<-1;
		return 0;
	}
	if((k-n)&1 && k>n)
	{
		cout<<-1;
		return 0;
	}
	if(k<n)
	{
		for(i=0;i<n;i++)
		{
		 for(j=0;j<n;j++)
		{
			if(i==j && k>0)
			cout<<"1 ", k--;
			else
			cout<<"0 ";
		}
		cout<<"\n";
	    }
	    return 0;
	}

	for(i=0;i<n;i++)
	b[i][i]=1;
	k-=n;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(k>0)
			b[i][j]=1, b[j][i]=1, k-=2;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		cout<<b[i][j]<<" ";
		cout<<"\n";
	}
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,MOD=1e9+7;
int ans[105][105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	file();

 	int n,k;

 	cin>>n>>k;

 	if(k>n*n)return cout<<"-1\n",0;

 	for(int i=0;i<n,k;i++,k--){
 		ans[i][i]=1;
 	}
 	if(k)
 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			if(!k)break;
 			if(ans[i][j])continue;
 			ans[i][j]=1;
 			k--;
 			if(!k)return cout<<"-1\n",0;
 			ans[j][i]=1;
 			k--;
 		}
 	}

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";
 		cout<<endl;
 	}

}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,MOD=1e9+7;
int ans[105][105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	file();

 	int n,k;

 	cin>>n>>k;

 	if(k>n*n)return cout<<"-1\n",0;

 	for(int i=0;i<n && k;i++,k--){
 		ans[i][i]=1;
 	}
 	if(k)
 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			if(!k)break;
 			if(ans[i][j])continue;
 			ans[i][j]=1;
 			k--;
 			if(!k)return cout<<"-1\n",0;
 			ans[j][i]=1;
 			k--;
 		}
 	}

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";
 		cout<<endl;
 	}

}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,MOD=1e9+7;
int ans[105][105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	file();

 	int n,k;

 	cin>>n>>k;

 	if(k>n*n)return cout<<"-1\n",0;

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			if(i==j && k) ans[i][j]=1,k--;
 			else if(!ans[i][j] && k>=2)ans[i][j]=ans[j][i]=1,k-=2;

 		}
 	}

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";
 		cout<<endl;
 	}
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,MOD=1e9+7;
int ans[105][105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	file();

 	int n,k;

 	cin>>n>>k;

 	if(k>n*n)return cout<<"-1\n",0;

 	for(int i=0;i<n && k;i++,k--){
 		ans[i][i]=1;
 	}
 	if(k)
 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			if(!k)break;
 			if(ans[i][j])continue;
 			if(i==j){
 				ans[i][i]=1;
 				k--;
 				continue;
 			}
 			if(k>=2){
	 			ans[i][j]=1;
	 			k--;
	 			ans[j][i]=1;
	 			k--;
 			}
 		}
 	}

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";
 		cout<<endl;
 	}

}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,MOD=1e9+7;
int ans[105][105];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	file();

 	int n,k;

 	cin>>n>>k;

 	if(k>n*n)return cout<<"-1\n",0;

 	for(int i=0;i<n && k;i++,k--){
 		ans[i][i]=1;
 	}
 	if(k)
 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			if(!k)break;
 			if(ans[i][j])continue;
 			if(i==j){
 				ans[i][i]=1;
 				k--;
 				continue;
 			}
 			ans[i][j]=1;
 			k--;
 			if(!k)return cout<<"-1\n",0;
 			ans[j][i]=1;
 			k--;
 		}
 	}

 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";
 		cout<<endl;
 	}

}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

int a[105][105];

int main() {
    ios_base::sync_with_stdio(0);
   // freopen("input.txt", "r", stdin);
 //   freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    if (k > n * n ) {
        cout << -1 << endl;
        return 0;
    }
    for (int i=0; i<n; i++) {
        int f = 0;
        for (int j=0; j<n; j++) {
            if (a[i][j] == 1) continue;
            if (k <= 1) {
                f = 1;
                break;
            }
          //  cerr << i << " " << j << " " << k << endl;
            if (i == j) k--;
            else k-=2;
            a[i][j] = 1;
            a[j][i]=1;
        }
        if (f == 1) break;
    }
    if (k == 1) {
        for (int i=0; i<n; i++) {
            if (a[i][i] == 0) {
                a[i][i] = 1;
                break;
            }
        }
    }
    if (k == -1) {
        for (int i=n-1; i>=0; i--) {
            if (a[i][i] == 1) {
                a[i][i] = 0;
                break;
            }
        }
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

int a[105][105];

int main() {
    ios_base::sync_with_stdio(0);
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    if (k > n * n ) {
        cout << -1 << endl;
        return 0;
    }
    for (int i=0; i<n; i++) {
        int f = 0;
        for (int j=0; j<n; j++) {
            if (k <= 1) {
                f = 1;
                break;
            }
            if (i == j) k--;
            else k-=2;
            a[i][j] = 1;
            if (i != j) a[n-i][n-j]=1;
        }
        if (f == 1) break;
    }
    if (k == 1) {
        for (int i=0; i<n; i++) {
            if (a[i][i] == 0) {
                a[i][i] = 1;
                break;
            }
        }
    }
    if (k == -1) {
        for (int i=n-1; i>=0; i--) {
            if (a[i][i] == 1) {
                a[i][i] = 0;
                break;
            }
        }
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;

int a[105][105];

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    if (k > n * n || (k > n && k % 2 == 1) ) {
        cout << -1 << endl;
        return 0;
    }
    for (int i=0; i<n/2; i++) {
        if (k <= 1) break;
        a[i][i]=1;
        a[n-i][n-i]=1;
        k-=2;
    }
    if (k == 1) {
      for (int i = 0 ; i<n; i++) {
            if (a[i][i] == 0) {
                a[i][i] = 1;
                break;
            }
        }
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                cout << a[i][j] << " ";
            }
            cout << endl;
        }
        return 0;
    }
    if (k == -1 ) {
        for (int i = n -1 ; i>=0; i--) {
            if (a[i][i] == 1) {
                a[i][i] = 0;
                break;
            }
        }
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                cout << a[i][j] << " ";
            }
            cout << endl;
        }
        return 0;
    }
    if (k == 0) {
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                cout << a[i][j] << " ";
            }
            cout << endl;
        }
        return 0;
    }
    for (int i=0; i<n; i++) {
        int f = 0;
        for (int j=0; j<n; j++) {
            if (k <= 0) {
                if (k == 0) f = 1;
                else f = 2;
                break;
            }
            if (a[i][j] == 1) continue;
            a[i][j] = 1;
            a[n-i][n-j]=1;
            k-=2;
        }
        if (f == 2) {
            cout << -1 << endl;
            return 0;
        }
        if (f == 1) break;
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}