#include using namespace std; int main() { int N, K; cin >> N >> K; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } int Q; cin >> Q; while (Q--) { int x, v; cin >> x >> v; A[x - 1] = v; // Update the array bitset<15001> dp; // 0..15000 dp[0] = 1; bool found = false; for (int a : A) { if (a == 0) continue; // 0 cannot contribute to the sum dp |= dp << a; if (dp.test(K)) { // Check if K is reachable now found = true; break; } } cout << (found ? 1 : 0) << '\n'; } return 0; }