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 t = int.Parse(Console.ReadLine());
            long[,] a = new long[t, 2];
            long[,] b = new long[t, 2];
            bool[] v = new bool[t];
            for(int i=0;i<t;i++)
            {
                string s = Console.ReadLine();
                string[] c = s.Split(' ');
                a[i, 0] = Convert.ToInt64(c[0]);
                a[i, 1] = Convert.ToInt64(c[1]);
                
            }
            for(int i=0;i<t;i++)
            {
                bool x = false;
                long j = 1;
                long l = a[i, 0] / 2;
                for (j = 1; ((j <= l) && !x); j = j + 2)
                {
                    if (a[i, 0] % j == 0)
                    {
                        if ((j ^ (a[i, 0] / j)) == a[i, 1])
                        {
                            x = true;
                            b[i, 0] = j;
                            b[i, 1] = a[i, 0] / b[i, 0];
                            v[i] = x;
                        }
                    }
                    if (a[i, 0] % l == 0 && !x)
                    {
                        if ((l ^ (a[i, 0] / l)) == a[i, 1])
                        {
                            x = true;
                            b[i, 0] = l;
                            b[i, 1] = a[i, 0] / b[i, 0];
                            v[i] = x;
                        }
                    }
                }
                if (v[i])
                {
                    Console.WriteLine(b[i, 0] + " " + b[i, 1]);
                }
                else Console.WriteLine(-1);
            }
        }
    }
}