T = int(input()) for i in range(T): N = int(input()) M = 1 while True: B = N * 10**len(str(M)) + M A = N + M if B % A == 0: print(M) break else: M += 1