#include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) typedef long long ll; using namespace std; int main() { const int Mod = 1000000009; const int N = 6; const int xs[N] = {1, 5, 10, 50, 100, 500}; const int Y = 500, X = Y * N; int dp[X + 1] = {}; dp[0] = 1; rep(i, N) { int x = xs[i]; for(int j = 0; j <= X - x; ++ j) (dp[j + x] += dp[j]) %= Mod; } int inv[N]; inv[1] = 1; for(int i = 2; i < N; ++ i) inv[i] = (ll)inv[Mod % i] * (Mod - Mod / i) % Mod; int T; cin >> T; rep(ii, T) { ll M; cin >> M; ll ans = 0; rep(i, N) { ll prod = 1; rep(j, N) if(i != j) (prod *= (M / Y - j) % Mod * inv[abs(i - j)] * (i < j ? -1 : 1) % Mod) %= Mod; (ans += prod * dp[i * Y + M % Y]) %= Mod; } if(ans < 0) ans += Mod; cout << ans << endl; } return 0; }