namespace _1_
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());
            bool p = false;
            int[,] para = new int[T, 2];
            for (int i = 0; i < T; i++)
            {
                string[] a = Console.ReadLine().Split();
                para[i, 0] = int.Parse(a[0]);
                para[i, 1] = int.Parse(a[1]);
            }
            for (int k = 0; k < T; k++)
            {
                if (para[k,0] == para[k,1])
                {
                    int z = para[k,1] - 1;
                    for (int i = 0; i < para[k,0]; i++)
                    {
                        for (int j = 0; j < para[k,1]; j++)
                        {
                            if(i == 0 || j == 0)
                                Console.Write(1+ " ");
                            else if (i + j <= para[k,0]-1)
                                Console.Write(0+" ");
                            else
                                Console.Write(1+" ");
                        }
                        z--;
                        Console.WriteLine();
                    }
                }
                else
                    Console.WriteLine(-1);
            }
        }
    }
}