#include using namespace std; using ll = long long; const ll MOD = 998462417; ll modpow(ll x, ll n, ll mod = MOD) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } const int MAXK = 15000; ll dp[MAXK + 1]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, K; cin >> n >> K; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; dp[0] = 1; for (int i = 0; i < n; i++) { if (a[i] == 0) continue; for (int j = K; j >= a[i]; j--) { (dp[j] += dp[j - a[i]]) %= MOD; } } int q; cin >> q; for (int i = 0; i < q; i++) { int x, v; cin >> x >> v; x--; for (int j = a[x]; j <= K; j++) { if (a[x] == 0) break; (dp[j] += (MOD - dp[j - a[x]])) %= MOD; } a[x] = v; for (int j = K; j >= v; j--) { if (v == 0) break; (dp[j] += dp[j - v]) %= MOD; } cout << (dp[K] > 0) << "\n"; } return 0; }