#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353; // Changed to standard CP modulo
void solve() {
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> dp(4000007, 0);
dp[0] = 1;
vector<int> hold(23);
hold[0] = hold[1] = 0;
// Precompute hold array
for(int i = 2; i < 23; i++) {
hold[i] = hold[i-1] * 2 + (1LL << i);
}
// DP computation
for(int i = 1; i <= 4e6+5; i++) {
for(int j = 0; j < 23; j++) {
if(i >= hold[j]) { // More efficient bounds check
dp[i] = (dp[i] + dp[i-hold[j]]) % MOD; // Inline modulo
}
}
}
// Output results
for(int x : a) {
cout << dp[x] << '\n'; // Using '\n' instead of endl for faster output
}
}
int32_t main() {
ios_base::sync_with_stdio(false); // Fast I/O
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgaW50IGxvbmcgbG9uZwpjb25zdCBpbnQgTU9EID0gOTk4MjQ0MzUzOyAgLy8gQ2hhbmdlZCB0byBzdGFuZGFyZCBDUCBtb2R1bG8KCnZvaWQgc29sdmUoKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgdmVjdG9yPGludD4gYShuKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gYVtpXTsKICAgIH0KICAgIAogICAgdmVjdG9yPGludD4gZHAoNDAwMDAwNywgMCk7CiAgICBkcFswXSA9IDE7CiAgICB2ZWN0b3I8aW50PiBob2xkKDIzKTsKICAgIGhvbGRbMF0gPSBob2xkWzFdID0gMDsKICAgIAogICAgLy8gUHJlY29tcHV0ZSBob2xkIGFycmF5CiAgICBmb3IoaW50IGkgPSAyOyBpIDwgMjM7IGkrKykgewogICAgICAgIGhvbGRbaV0gPSBob2xkW2ktMV0gKiAyICsgKDFMTCA8PCBpKTsKICAgIH0KICAgIAogICAgLy8gRFAgY29tcHV0YXRpb24KICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gNGU2KzU7IGkrKykgewogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCAyMzsgaisrKSB7CiAgICAgICAgICAgIGlmKGkgPj0gaG9sZFtqXSkgeyAgLy8gTW9yZSBlZmZpY2llbnQgYm91bmRzIGNoZWNrCiAgICAgICAgICAgICAgICBkcFtpXSA9IChkcFtpXSArIGRwW2ktaG9sZFtqXV0pICUgTU9EOyAgLy8gSW5saW5lIG1vZHVsbwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgCiAgICAvLyBPdXRwdXQgcmVzdWx0cwogICAgZm9yKGludCB4IDogYSkgewogICAgICAgIGNvdXQgPDwgZHBbeF0gPDwgJ1xuJzsgIC8vIFVzaW5nICdcbicgaW5zdGVhZCBvZiBlbmRsIGZvciBmYXN0ZXIgb3V0cHV0CiAgICB9Cn0KCmludDMyX3QgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyAgLy8gRmFzdCBJL08KICAgIGNpbi50aWUoTlVMTCk7CiAgICAKICAgIGludCB0ID0gMTsKICAgIC8vY2luID4+IHQ7CiAgICB3aGlsZSh0LS0pIHsKICAgICAgICBzb2x2ZSgpOwogICAgfQogICAgcmV0dXJuIDA7Cn0=