N, K = map(int, input().split()) datas = list(map(int, input().split())) def process_data(datas, key, N): S = [0] * (N+1) current = 0 for i in range(N): current |= datas[i] if current == key: S[i+1] = S[i] + 1 else: S[i+1] = S[i] return S key = (1 << K) - 1 Q = int(input()) S = process_data(datas, key, N) for _ in range(Q): query = list(map(int, input().split())) if query[0] == 1: _, i, v = query datas[i-1] = v S = process_data(datas, key, N) elif query[0] == 2: _, l, r = query if S[r] - S[l-1] > 0: print(r - l + 1) else: print(-1)