Q = int(input()) ans = [] for _ in range(Q): s = input() ans.append(int(s, 0)) print(*ans, sep="\n")