import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.conv, std.stdio, std.typecons; const auto mod = 10 ^^ 9 + 9; void main() { auto t = readln.chomp.to!int; auto mi = iota(t).map!(_ => readln.chomp.to!long); auto ni = mi.map!(m => (m / 111111).to!int).array; auto maxN = ni.reduce!(max); auto memo = new int[](maxN + 1); memo[] = 1; foreach (i; 1..10) { auto memo2 = new int[](maxN + 1); foreach (j; 0..maxN + 1) { memo2[j] = (memo[j] + (j >= i ? memo2[j - i] : 0)) % mod; } foreach (j; 0..maxN + 1) { memo[j] = (memo[j] + (j >= i ? memo2[j - i] : 0)) % mod; } } foreach (n; ni) writeln(memo[n]); }