#include using namespace std; typedef long long int ll; typedef unsigned long long int llu; typedef pair pii; typedef vector vi; typedef vector > vii; #define rrep(i, m, n) for(int i=m; i=m; i--) #define erev(i, n) for(int i=n; i>=1; i--) #define rev(i, n) for(int i=n-1; i>=0; i--) #define EACH(v) (v).begin(), (v).end() #define CNT(a, n, x) (upper_bound(a, a+n, x)-lower_bound(a, a+n, x)) #define minup(m, x) (m=min(m, x)) #define maxup(m, x) (m=max(m, x)) #define mp make_pair #define INF 1000000000 #define MOD 1000000009 #define EPS 1E-9 #define MAX_T 10000 #define MAX_M 10000000000 #define DIV (MAX_M/111111) int t; ll m[MAX_T]; ll dp[DIV+1]; int main() { cin >> t; rep(i, t) cin >> m[i]; rep(i, DIV+1) dp[i] = 1; erep(i, 9) rrep(j, i, DIV+1) dp[j] = (dp[j] + dp[j-i]) % MOD; rep(i, t) cout << dp[m[i]/111111] << endl; return 0; }