import sys from itertools import accumulate sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) mod = 10**9+9 X = (10**10)//111111 dp = [[0]*(X+1) for i in range(10)] # dp[i][j] = (1*a1+2*a2+…+i*ai == j の解の個数) dp[0][0] = 1 for i in range(1,10): for j in range(X+1): a = dp[i-1][j] if j >= i: a += dp[i][j-i] a %= mod dp[i][j] = a A = dp[-1] SA = list(accumulate(A)) T = I() for _ in range(T): M = I() M //= 111111 print(SA[M] % mod)