N,K=map(int,input().split()) A=list(map(int,input().split())) mod=(1<<61)-1 P=[0]*(K+1) P[0]=1 for a in A: if a: for k in range(K,a-1,-1): P[k]+=P[k-a] P[k]%=mod Q=int(input()) for q in range(Q): x,v=map(int,input().split()) x-=1 if A[x]: for k in range(A[x],K+1): P[k]-=P[k-A[x]] P[k]%=mod A[x]=v if A[x]: for k in range(K,A[x]-1,-1): P[k]+=P[k-A[x]] P[k]%=mod if P[K]: ans=1 else: ans=0 print(ans)