t = int(input()) for _ in range(t): n = int(input()) for digit in range(1, 18): m = pow(10, digit) - n - 1 if m < 0: continue if len(str(m)) == digit: print(m) break