using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());
            for (int u = 0; u < T; u++)
            {
                string[] s = Console.ReadLine().Split();
                int n = int.Parse(s[0]);
                int m = int.Parse(s[1]);
                int[] sume_i = new int[1000000000];
                int[] sume_j = new int[1000000000];
                int[,] mat = new int[n + 1, m + 1];
                for (int i = 1; i <= n; i++)
                    for (int j = 1; j <= m; j++)
                    {
                        mat[i, j] = 1;
                    }
                if (n != m)
                    Console.WriteLine("-1");
                
            }
        }
    }
}