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

namespace ConsoleApp1
{
    class Program
    {
        static long myXOR(long x, long y)
        {
            return (x | y) & (~x | ~y);
        }

        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            long[,] skr = new long[t, 2];
            ulong[,] pada = new ulong[t, 2];
            for (int i = 0; i < t; i++)
            {
                string[] x = Console.ReadLine().Split();
                pada[i, 0] = Convert.ToUInt64(x[0]);
                pada[i, 1] = Convert.ToUInt64(x[1]);
            }
            for (int i = 0; i < t; i++)
            {
                for (long j = (long)Math.Sqrt(a); j > 0; j--)
                {
                    if (pada[i,0] % (ulong)j == 0 && (ulong)(myXOR(j, (long)(pada[i,0] / (ulong)j))) == pada[i,1])
                    {
                        skr[i, 0] = j;
                        skr[i, 1] = (long)(pada[i,0] / (ulong)j);
                        break;
                    }
                }
            }
            for (int i = 0; i < t; i++)
            {
                if (skr[i, 0] != 0 && skr[i, 1] != 0)
                    Console.WriteLine(skr[i, 0] + " " + skr[i, 1]);
                else
                    Console.WriteLine("-1");
            }
        }
    }
}