Q = int(input()) S = [input() for _ in range(Q)] for s in S: print(int(s, 0))