N, Q = map(int, input().split()) A = list(map(int, input().split())) for _ in range(Q): L, R = map(int, input().split()) for i in range(L-1, R): A[i] = 1 - A[i] for i in A: print(i)