#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=0;cin>>t;
while(t--)
{
long long int a,b,num;
long long int n=1;
cin>>a>>b>>num;
for(long long int i=1;i<=a;i++)
{
n=(n*a)+b;
}
cout<<n<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIAp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoTlVMTCk7CiAgICBpbnQgdD0wO2Npbj4+dDsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgbG9uZyBsb25nIGludCBhLGIsbnVtOwogICAgbG9uZyBsb25nIGludCBuPTE7CiAgICBjaW4+PmE+PmI+Pm51bTsKICAgIGZvcihsb25nIGxvbmcgaW50IGk9MTtpPD1hO2krKykKICAgIHsKICAgICAgICBuPShuKmEpK2I7CiAgICB9CiAgICBjb3V0PDxuPDxlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0=