using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kval13
{
    class Program
    {
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());
            long[] a = new long[T];
            long[] b = new long[T];
            for (int i = 0; i < T; i++)
            {
                string line = Console.ReadLine();
                int blanko = line.IndexOf(' ');

                a[i] = (line[0]) - '0';
                for (int j = 1; j < blanko; j++)
                {
                    a[i] = a[i] * 10 + (line[j] - '0');
                }

                b[i] = line[blanko + 1] - '0';
                for (int j = blanko+2; j < line.Length; j++)
                {
                    b[i] = b[i] * 10 + (line[j] - '0');
                }
            }

            for (int i = 0; i < T; i++)
            {
                if (a[i] % 2 == 0)
                    Console.WriteLine(-1);
                else
                {
                    int d = 1;
                    bool p = false;
                    int maksimalniCinilac = (int)Math.Sqrt(a[i]) +1;

                    int y = 1;
                    long x;

                    while ((y <maksimalniCinilac) && !p)
                    {
                        x = ~(b[i] ^ (~y));
                        if (x * y == a[i])
                        {
                            p = true;
                            Console.WriteLine("{0} {1}", x, y);
                        }
                        y += 2;
                    }

                    if (!p) Console.WriteLine(-1);
                }
            }
        }
    }
}