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

namespace takm
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            List<string> arr = new List<string>();
            for(int i=0;i<t;i++)
            {
                string[] row = Console.ReadLine().Split();

                ulong a = ulong.Parse(row[0]);
                ulong b = ulong.Parse(row[1]);

                f(ref a, ref b);
                if (a == 0)
                    arr.Add("-1");
                else
                    arr.Add(a + " " + b);
            }

            foreach (object i in arr)
                Console.WriteLine(i);
        }

        static void f(ref ulong a, ref ulong b)
        {
            uint sq=(uint)Math.Floor(Math.Sqrt(a));
            for(uint i=1;i<=sq;i+=2)
            {
                uint j = (uint)a / i;
                if(b==(i^(a/i)))
                {
                    a = i;
                    b = j;
                    return;
                }
            }
            a = 0;
        }
    }
}