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