#include #include #include #include #include #define repf(x,from,to) for(int (x)=(from);(x)<(to);(x)++) typedef long long ll; using namespace std; int main() { const ll MOD=1000000009, MMX=10000000000; map mp; vector su; repf(i,1,10) su.push_back(111111*i); mp[0]=1LL;mp[MMX*2]=0LL; repf(i,0,9) for(auto& x: mp){ if(su[i]+x.first <= MMX) (mp[su[i]+x.first] += x.second) %=MOD; } ll w=0; for(auto& x: mp){ (x.second += w)%=MOD; w=x.second; } int T; cin >> T; while( T--){ ll M; cin >> M; auto it = mp.upper_bound(M); it--; cout << it->second <