# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,k = map(int,readline().split()) *a, = map(int,readline().split()) def mul(c,m,dp): #multiply (1+x^c) up to x^m for i in range(m,c-1,-1): dp[i] += dp[i-c] dp[i] %= MOD def div(c,m,dp): #divide by (1+x^c) up to x^m for i in range(m-c+1): dp[i+c] -= dp[i] dp[i+c] %= MOD MOD = 10**9+7 dp = [0]*(k+1) dp[0] = 1 for i in a: mul(i,k,dp) q = int(readline()) for _ in range(q): x,v = map(int,readline().split()) if a[x-1]: div(a[x-1],k,dp) if v: mul(v,k,dp) a[x-1] = v print(1 if dp[-1] else 0)