N,Q = map(int,input().split()) A = list(map(int,input().split())) S = [0] * (N + 1) for _ in range(Q): l,r = map(int,input().split()) S[l-1] += 1 S[r]-=1 for i in range(N): if i > 0: S[i] += S[i-1] if S[i] & 1: A[i] = 1 - A[i] print(*A)