T = int(input()) for _ in range(T): N = int(input()) for m in range(1, N): a = N+m b = N*10**(len(str(m)))+m if b%a==0: print(m) break