using System;
static void Main(string[] args)
{

    //prvi zadatak
    int t = int.Parse(Console.ReadLine());
    for (int i = 0; i < t; i++)
    {
        bool a = false;
        string[] s = Console.ReadLine().Split();
        int brr = int.Parse(s[0]);
        int brk = int.Parse(s[1]);
        int[,] m = new int[brr, brk];
        if (brr != brk || brr > 4){
            Console.WriteLine(-1);
            a = true;
        }
        if (!a){
            m[0, 0] = 1;
            for (int r = 1; r < brr; r++){
                for (int k = 1; k < brk; k++){
                    if (r==0||k==0|| k==brk-1|| r==brr-1|| (r==2&&k==2)) m[r, k] = 1;
                    Console.Write(m[r, k]);
                }
                Console.WriteLine();
            }
        }
        
    }
}