using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
namespace _1_
{
    internal class Program
    {
        public static void Ispis(int[,] a)
        {
            for(int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    Console.Write(a[i,j]+  " ");
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            int T=int.Parse(Console.ReadLine());
            Dictionary<int, int> dimenzije = new Dictionary<int, int>();
            for(int i = 0; i < T; i++)
            {
                int[] pom = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (pom[0] == pom[1])
                {
                    dimenzije.Add(pom[0], pom[1]);
                }
                else
                {
                    dimenzije.Add(-1, -1);
                }
            }
            foreach(var dimenzija in dimenzije)
            {
                if(dimenzija.Key == -1)
                    {
                    Console.WriteLine(-1);
                    continue;
                }
                int[,] a = new int[dimenzija.Key,dimenzija.Value];
                for (int i = 1; i <= dimenzija.Key; i++)
                {
                    for (int j = 1; j <= dimenzija.Value; j++)
                    {
                        if (i == 1 || j == 1 || i == a.GetLength(0) || j == a.GetLength(1))
                        {
                            //a[i - 1, j - 1] = 1;
                            Console.Write(1 + " ");
                        }
                        else if (i % 2 == 1 && j % 2 == 1)
                        {
                            //a[i - 1, j - 1] = 1;
                            Console.Write(1 +" ");
                        }
                        else
                        {
                            //a[i - 1, j - 1] = 0;
                            Console.Write(0 + " ");
                        }
                    }
                    Console.WriteLine();
                }
            }
        } 
    }
}