#include <iostream>
#include <algorithm>
#include <math.h>

int main(){
	
	int t ;
	std::cin>>t;
	
	unsigned long long int A [t]  ;
	unsigned long long int B [t]  ;
	
	for(int i=0;i<t;i++){
		std::cin>>A[i]>>B[i];
	}
	
	for(int g =0; g<t;g++){
		
		
		int x=(B[g]+sqrt( B[g]*B[g]+4*A[g] ))/2;
		int y =A[g]/x;
		if(x*y==A[g]&&std::max(x,y)-std::min(x,y)==B[g]){
			std::cout<<x<<" "<<y<<std::endl;
		}
		else{
			std::cout<<-1<<std::endl;
		}
	 
	 
	 				
 	}
	
		
		
		
	return 0;
}