import java.util.*; public class Main { static final int MOD = 1000000009; static int[][] dp = new int[9][90001]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < dp[0].length; i++) { dp[0][i] = i + 1; } for (int i = 1; i < 9; i++) { for (int j = 0; j < dp[i].length; j++) { if (j <= i) { dp[i][j] = dp[i - 1][j]; } else { dp[i][j] = (dp[i - 1][j] + dp[i][j - i - 1]) % MOD; } } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); int y = (int)(x / 111111); sb.append(dp[8][y]).append("\n"); } System.out.print(sb); } }