#include using namespace std; int main() { int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector D(N + 1, 0); for (int i = 0; i < Q; i++) { int L, R; cin >> L >> R; L--; R--; D[L] += 1; if (R + 1 < N) { D[R + 1] -= 1; } } int flip = 0; for (int i = 0; i < N; i++) { flip += D[i]; if (flip % 2 == 1) { A[i] = 1 - A[i]; } } for (int i = 0; i < N; i++) { cout << A[i] << " "; } cout << endl; return 0; }