program zad5;
var t,a,b,i,j,m:longint;
flg:boolean;
begin
  read(t);
  for i:=1 to t do
    begin
      read(a,b);
      for j:=1 to (a div 2) do
        begin
        for m:=1 to (a div 2) do
          begin
            if ((m*j)=a) and (m xor j = b) then
            begin
              writeln(m,' ',j);
              flg:=true;
              break;
            end
            else flg:=false;
          end;

        if flg = true then
          begin
            break;
          end;
        end;
      if flg=true then else writeln(-1);
    end;
end.