N,Q=map(int,input().split()) A=list(map(int,input().split())) X=[0]*(N+3) for i in range(Q): x,y=map(int,input().split()) X[x-1]+=1 X[y]+=1 for i in range(1,N+3): X[i]+=X[i-1] for i in range(N): if X[i]%2==1: A[i]^=1 print(*A)