#include #include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) int MOD = 1000000009; int dp[10][100000]; #if 0 int solve(ll N){ memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for(int i = 1; i <= 9; i++){ for(int j = 0; j <= N; j++){ for(int k = 0; k <= N; k++){ if(j+k*i > N) break; dp[i][j+k*i] = (dp[i][j+k*i] + dp[i-1][j]) % MOD; } } } int result = 0; for(int i = 0; i <= N; i++){ result = (result + dp[9][i]) % MOD; } return result; } #endif int memo[10][100000]; int dfs(ll N, int i){ int result = 0; if(i >= 10) return 1; if(memo[i][N] >= 0) return memo[i][N]; for(int j = 0; j <= N; j += i){ result = (result + dfs(N-j, i+1)) % MOD; } return memo[i][N] = result; } int solve(ll N){ memset(memo, -1, sizeof(memo)); return dfs(N, 1); } int main(){ int T; cin >> T; REP(i,T){ ll N; cin >> N; cout << solve(N/111111) << endl; } return 0; }