#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 imos(n + 1); while (q--) { int l, r; cin >> l >> r; l--; imos[l]++; imos[r]--; } for (int i = 1; i <= n; i++) { imos[i] += imos[i - 1]; } for (int i = 0; i < n; i++) { cout << (imos[i] % 2 == 0 ? a[i] : 1 - a[i]) << " "; } cout << endl; }