import java.util.*; public class Main { public static void main(String[] args) { long MOD = (long)Math.pow(10, 9) + 9; Scanner sc = new Scanner(System.in); // dp[i][j]はx1+...+i * xi=jの非負整数解の個数mod MOD long[][] dp = new long[10][100001]; for(int j = 0; j < 100001; j++) { dp[1][j] = 1; } for(int i = 2; i < 10; i++) { dp[i][0] = 1; for(int j = 1; j < 100001; j++) { dp[i][j] = dp[i - 1][j]; if(j >= i) dp[i][j] = (dp[i][j] + dp[i][j - i]) % MOD; } } long[] sum = new long[100001]; sum[0] = dp[9][0]; for(int j = 1; j < 100001; j++) { sum[j] = (sum[j - 1] + dp[9][j]) % MOD; } int T = sc.nextInt(); for(int i = 0; i < T; i++) { long m = sc.nextLong(); System.out.println(sum[(int)((m - (m % 111111)) / (long)111111)]); } } }