N, Q = map(int, input().split()) A = list(map(int, input().split())) D = [0] * (N + 1) for i in range(Q): L, R = map(int, input().split()) L -= 1 D[L] ^= 1 D[R] ^= 1 for i in range(N): D[i + 1] ^= D[i] ans = [] for i in range(N): ans.append(A[i] ^ D[i]) print(*ans)