import java.util.*; public class Main { static int[][] dp; static final int MOD = 1000000009; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int max = (int)(10000000000L / 111111); dp = new int[10][max + 1]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { int x = (int)(sc.nextLong() / 111111); sb.append(dfw(9, x)).append("\n"); } System.out.print(sb); } static int dfw(int idx, int value) { if (value == 0 || idx == 0) { return 1; } if (idx == 1) { return value + 1; } if (dp[idx][value] == 0) { if (idx > value) { dp[idx][value] = dfw(idx - 1, value); } else { dp[idx][value] = (dfw(idx - 1, value) + dfw(idx, value - idx)) % MOD; } } return dp[idx][value]; } }