int T = int.Parse(Console.ReadLine());
int n = 0;
int m = 0;
Queue<int> q = new Queue<int>();
for (int i = 0; i < T; i++)
{
    string[] NM = Console.ReadLine().Split();
    n = int.Parse(NM[0]);
    m = int.Parse(NM[1]);
    q.Enqueue(n);
    q.Enqueue(m);
    
}
for (int k  = 0; k < T; k++)
{
    int n1 = q.Dequeue();
    int m1 = q.Dequeue();
    int brI = 0;
    if (n1 != m1) Console.WriteLine(-1);
    else if (n1 ==m1)
    {
        for (int i = 0; i < n1; i++)
        {
            for (int j = 0; j < m1; j++)
            {
                if (i == 0 || i == n1 - 1) {Console.Write(1); continue;}
                if (brI < i + 1) 
                {
                    if (j == 0 || j == m1 - 1) { Console.Write(1); continue; }
                    else if (j == m1 - i) Console.Write(1);
                    else { Console.Write(0); continue; }
                }
                else Console.Write(0);
            }
            Console.WriteLine();
            brI = 0;
        }
    }
}