T = int(input()) for i in range(T): N = int(input()) C = N+1 print(10**(len(str(C)))-C)