#include <iostream>
using namespace std;
int main(){
int t;
bool flag;
cin>>t;
char p[35],q[35],r[35];
int p2,q2,r2;
while(t--){
scanf("%s %s %s", p, q, r);
flag=false;
for(int i=2; i<=16; i++){
p2 = strtol(p, NULL, i);
q2 = strtol(q, NULL, i);
r2 = strtol(r, NULL, i);
if(p2*q2==r2 && p2!=0 && q2!=0){
cout<<i<<endl;
flag=true;
break;
}
}
if(flag==false)
cout<<"0"<<endl;
}
return 0;
}
G++ Compile Error
C++ AC
http://my.oschina.net/dianpaopao/blog/82403