#include #include using namespace std; int gcd(int a,int b) { while(b) { int t=a%b; a=b; b=t; } return a; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T;cin>>T; for(;T--;) { int A,B; long K; cin>>A>>B>>K; int g=gcd(A,B); long lcm=(long)A/g*B; long L=0,R=4e18; while(R-L>1) { long M=(L+R)/2; if(M-(M/A+M/B-M/lcm)>=K)R=M; else L=M; } cout<