def mul(c,m): for i in range(m,c-1,-1): dp[i] = (dp[i]+dp[i-c])%MOD def div(c,m): for i in range(m-c+1): dp[i+c] = (dp[i+c]-dp[i])%MOD n,k = map(int,input().split()) *a, = map(int,input().split()) MOD = 1<<59+1 dp = [0]*(k+1) dp[0] = 1 for i in a: mul(i,k) q = int(readline()) for _ in range(q): x,v = map(int,readline().split()) if a[x-1]: div(a[x-1],k) if v: mul(v,k) a[x-1] = v print(1 if dp[-1] else 0)