Q = int(input()) for _ in range(Q): s = input().strip() print(int(s, 0))