#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n), imos(n + 1);
    cin >> a;
    while(q--){
        int l, r;
        cin >> l >> r;
        l--;
        imos[l] ^= 1;
        imos[r] ^= 1;
    }
    for(int i = 0; i < n; i++){
        imos[i + 1] ^= imos[i];
        a[i] ^= imos[i];
    }
    cout << a << '\n';
}