#include using namespace std; #define int long long int f(int a,int b,int x) { return x-x/a-x/b+x/(a*b/__gcd(a,b)); } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--) { int a,b,k;cin>>a>>b>>k; int low=0;int up=8e18; while(up-low>1) { int mid=(low+up)/2; if(f(a,b,mid)>=k) up=mid; else low=mid; } cout<