N = int(input()) for _ in range(N): s = list(input()) s.reverse() val = 0 for i in range(5): val += int(s[i])*(10**i) print(val)