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