转换好进制 输出A/B A%B
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <cmath>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
typedef long long LL;
typedef long double LD;
const double pi=acos(-1.0);
const double eps=1e-6;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
typedef pair<double, int> PI;
typedef pair<int, PI> PP;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
//#pragma comment(linker, "/STACK:1024000000,1024000000")
//LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}
//inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;}
//inline void print(LL x){printf(LLD, x);puts("");}
//inline void read(double &ret){char c;int sgn;double bit=0.1;if(c=getchar(),c==EOF) return ;while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();sgn=(c=='-')?-1:1;ret=(c=='-')?0:(c-'0');while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');if(c==' '||c=='\n'){ ret*=sgn; return ; }while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;ret*=sgn;}
char s1[22222],s2[22222];
int c,a,b;
int getnum(char s[])
{
int len=strlen(s);
int x=1,ans=0;
for(int i=len-1;i>=0;i--)
{
int cc;
if(s[i]>='0'&&s[i]<='9')
cc=s[i]-'0';
else cc=s[i]-'a'+10;
ans+=x*cc;
x*=c;
}
return ans;
}
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%s %s %d",s1,s2,&c);
a=getnum(s1);
b=getnum(s2);
printf("(%d,%d)\n",a/b,a%b);
}
return 0;
}