#include using namespace std; using ll = long long; using modint = atcoder::static_modint<1000000009>; int main(){ ios::sync_with_stdio(false); cin.tie(0); vector dp(3000, 1); vector coin = {1, 5, 10, 50, 100, 500}; for(int i = 1; i < coin.size(); i++){ for(int j = coin[i]; j < 3000; j++){ dp[j] += dp[j - coin[i]]; } } int T; cin >> T; while(T--){ long long M, m; cin >> M; if(M < 3000){ cout << dp[M].val() << '\n'; continue; } m = M % 500; modint ans; for(int i = m; i < 3000; i += 500){ modint c = 1, d = 1; for(int j = m; j < 3000; j += 500){ if(j == i)continue; c *= (M - j); d *= (i - j); } ans += dp[i] * c / d; } cout << ans.val() << '\n'; } }