import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 9; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): T = int(input()) DP = [[0] * (10 ** 5 + 10) for i in range(10)] DP[0][0] = 1 for i in range(9): for j in range(10 ** 5): DP[i][j + (i + 1)] += DP[i][j] DP[i + 1][j] += DP[i][j] DP[i][j + (i + 1)] %= con DP[i + 1][j] %= con # 累積 DPs = [0] * (10 ** 5 + 1) DPs[0] = DP[-1][0] for i in range(1, 10 ** 5 + 1): DPs[i] = (DPs[i - 1] + DP[-1][i]) % con for i in range(T): M = int(input()) M = int(M // 111111) print(DPs[M]) if __name__ == '__main__': main()