#include using namespace std; const int MAX_K = 15000; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; vector A(N); for (int &a : A) cin >> a; int Q; cin >> Q; bitset dp; while (Q--) { int x, v; cin >> x >> v; x--; // Convert to 0-based index A[x] = v; dp.reset(); dp[0] = true; bool found = false; for (int a : A) { if (a == 0 || a > K) continue; dp |= dp << a; if (dp[K]) { found = true; break; } } cout << found << '\n'; } return 0; }