#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>Q; while(Q--){ ll a,b,k;cin>>a>>b>>k; ll left=0,right=1LL<<61; while(right-left>1){ ll mid=(left+right)/2; ll sum=mid; sum-=mid/a; sum-=mid/b; sum+=mid/(a*b/gcd(a,b)); if(sum>=k) right=mid; else left=mid; } cout<