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

namespace Luxor
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            ulong[,] a = new ulong[n, 2];
            for(int i = 0; i<n; i++)
            {
                string line = Console.ReadLine();
                var data = line.Split(' ');
                a[i,0]=ulong.Parse(data[0]);
                a[i, 1] = ulong.Parse(data[1]);
            }
            for (int i = 0; i < n; i++)
            {
                ulong j = 1;
                while (j <= a[i, 1]) j *= 2;
                j /= 2;
                int t;
                t = 0;
                ulong p = 0;
                ulong q = 0;
                for (j = 1; j <= Math.Sqrt(a[i, 0]); j+=2)
                {
                    if (a[i, 0] % j == 0)
                    {
                        ulong x = j ^ (a[i, 0] / j);
                        if (x == a[i, 1])
                        {
                            p = j;
                            q = a[i, 0] / j;
                            t = 1;
                        }
                        else t = 0;
                    }
                }
                if (t == 0) Console.WriteLine("-1");
                else Console.WriteLine(p.ToString() + " " + q.ToString());
            }
        }
    }
}