一开始想复杂了,若a,b都是G的倍数,则L也是G的倍数,所以如果L%G!=0,那么一定不存在,且发现a=G,b=L
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int T;
long long G,L;
cin>>T;
while(T--){
cin>>G>>L;
if(L%G!=0) cout<<"-1"<<endl;
else cout<<G<<" "<<L<<endl;
}
return 0;
}