#include<cstdio>
using namespace std;
int T, temp;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&temp);
printf("%d
",temp-1);
}
}
#include<cstdio>
using namespace std;
char p, q;
void jud1(int y)
{
if(0 <= y && y <= 9)
p = y+'0'-0;
else
p = 'A' - 10 + y;
}
void jud2(int y)
{
if(0 <= y && y <= 9)
q = y+'0'-0;
else
q = 'A' - 10 + y;
}
void con(int x)
{
int a = x / 16;
jud1(a);
int b = x % 16;
jud2(b);
}
int main()
{
int x, y, z;
while(scanf("(%d, %d, %d)",&x,&y,&z)!= EOF)
{
//int x, y, z;
//scanf("(%d, %d, %d)",&x,&y,&z);
con(x);
printf("#%c%c",p,q);
con(y);
printf("%c%c",p,q);
con(z);
printf("%c%c
",p,q);
}
}