using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace Petlja_5
{
    class Par
    {
        public BigInteger A { get; set; }
        public BigInteger B { get; set; }
        public BigInteger X { get; set; }
        public BigInteger Y { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            BigInteger brojParova = BigInteger.Parse(Console.ReadLine());
            List<Par> parovi = new List<Par>();
            for (int i = 0; i < brojParova; i++)
            {
                string[] unos = Console.ReadLine().Split();
                parovi.Add(new Par { A = BigInteger.Parse(unos[0]), B = BigInteger.Parse(unos[1]) });
                bool notFound = true;
                BigInteger Y = 1;
                BigInteger X = 1;
                Par p = parovi[i];
                while (notFound)
                {
                    if (p.B == ((p.A / Y) ^ Y)) //Xi = Ai/Yi
                    {
                        X = p.A / Y;
                        p.X = X;
                        p.Y = Y;
                        notFound = false;
                        Console.WriteLine(p.Y + " " + p.X);
                        break;
                    }
                    Y++;
                    if (Y > BigInteger.Max(p.A, p.B))
                    {
                        p.Y = -1;
                        Console.WriteLine(-1);
                        break;
                    }
                }
            }
        }
    }
}