#include using namespace std; using i64 = long long; #define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++) #define all(x) x.begin(),x.end() #define let auto const int main() { i64 N, K; cin >> N >> K; vector A(N + 1); rep(i,1,N + 1) cin >> A[i]; i64 mod = (1ll << 55) + 55; vector dp(K + 1, 0); dp[0] = 1; auto fix = [mod](i64 m) { if(m < 0) return m + mod; if(m >= mod) return m - mod; return m; }; rep(i,1,N + 1) { if(A[i] != 0) { for(int j = K; j >= A[i]; j--) { dp[j] = fix(dp[j] + dp[j - A[i]]); } } } i64 Q; cin >> Q; rep(q, 0, Q) { i64 x, v; cin >> x >> v; if(A[x] != 0) { for(int j = A[x]; j <= K; j++) { dp[j] = fix(dp[j] - dp[j - A[x]]); } } A[x] = v; if(A[x] != 0) { for(int j = K; j >= A[x]; j--) { dp[j] = fix(dp[j] + dp[j - A[x]]); } } cout << (dp[K] != 0) << endl; } }