package luxor_reljadjenadic.relja348;

import java.util.Scanner;

public class Luxor_ReljaDjenadicRelja348 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        long[][] matrica = new long[t][2];
        long br;
        for (int i = 0; i < t; i++) {
                br = in.nextLong();
                if (br%2==0) {
                    i--;
                    continue;
                }else{
                    matrica[i][0] = br;
                }
                matrica[i][1] = in.nextLong();
        }
        boolean boi = false;
        long x, y;
        for (int j = 0; j < t; j++) {
            for (int i = 1; i < (matrica[j][0]+1) / 2; i++) {
                boi = false;
                if (matrica[j][0] % i == 0) {
                    x = i;
                    y = matrica[j][0] / i;
                    if (((x|y)&(~x|~y))== matrica[j][1]) {
                        System.out.println(x + " " + y);
                        boi = true;
                        break;
                    }
                    
                }
            }
            if (boi == false) {
                System.out.println("-1");
            }
            
        }
        
        
    }
    
}