import java.io.*; import java.util.*; public class Main_yukicoder41 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); final int MOD = 1_000_000_009; int n = (int)(10_000_000_000L / 111111); long[] dp = new long[n + 1]; dp[0] = 1; for (int j = 0; j <= 9; j++) { int tmp; if (j == 0) { tmp = 1; } else { tmp = j; } for (int i = tmp; i <= n; i++) { dp[i] = (dp[i - tmp] + dp[i]) % MOD; } } int t = sc.nextInt(); for (int tcase = 0; tcase < t; tcase++) { long m = sc.nextLong(); pr.println(dp[(int)(m / 111111)]); } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }