#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5;
int a,b;
void solve(){
scanf("%lld%lld",&a,&b);
int p=a/__gcd(a,b)*b;
if(b%a==0) cout<<b*b/a<<endl;
else cout<<p<<endl;
}
signed main(){
int t=1;
scanf("%lld",&t);
while(t--) solve();
return 0;
}