#include <stdio.h>
int main(void)
{
long in, res;
int ri, repeat;
long reverse(long number);
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%ld", &in);
res = reverse(in) ;
printf("%ld\n", res);
}
}
long reverse(long number)
{
int i;
long n, result=0;
if (number == 0) return 0;
else if (number < 0 ) n = -number;
else n = number;
while(n>0)
{
result *= 10;
i = n % 10;
n /= 10;
result += i;
}
if (number < 0) result = -result;
return result;
}