放码子:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int gcd(int a,int b){
int temp;
if(a<b){
temp=a;
a=b;
b=temp;
}
while(a%b){
temp=a%b;
a=b;
b=temp;
}
return b;
}
int main(){
int n;
int a,b;
cin>>n;
for(int i=0;i<n;i++){
cin>>a>>b;
for(int j=2;j<=a;j++){
if(b==gcd(a,b*j)){
cout<<b*j<<endl;
break;
}
}
}
return 0;
}