/* * Author: asharusmani * Created: Wednesday, 03.12.2025 10:26 PM (GMT+5:30) * * ? If the world was ending, I'd wanna be next to you ? * ? If the party was over and our time on Earth was through ? * ? I'd wanna hold you just for a while... and die with a smile ? */ #include "bits/stdc++.h" using namespace std; #ifndef ONLINE_JUDGE #define DEBUG 1 #endif #if DEBUG #define del cerr << '\n' #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__) template ostream& operator<<(ostream& os, pair const& p) { return os << "(" << p.first << ", " << p.second << ")"; } template basic_ostream& operator<<(basic_ostream& os, Container const& x) { int i = 0, n = distance(x.begin(), x.end()); os << "{ "; for (const auto& y : x) os << y << (++i < n ? ", " : ""); return os << " }"; } template void _debug(const char* names, Args&&... args) { string_view s(names); cerr << "{ "; size_t i = 0, cnt = 0, n = sizeof...(args); auto next = [&]() { while (i < s.size() && (s[i] == ' ' || s[i] == ',')) ++i; size_t st = i; while (i < s.size() && s[i] != ',') ++i; return s.substr(st, i - st); }; ((cerr << next() << ": " << args << (++cnt < n ? ", " : "")), ...); cerr << " }" << '\n'; } #else #define del #define debug(...) #endif #define ll long long #define nl endl #define double long double #define pb push_back #define forn(i,a,n) for(int i=a;i template using min_heap = priority_queue, greater>; #define fastnuces ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t = 1; #define yesno(b) cout << ((b)? "YES\n" : "NO\n") void solve() { int n, q; cin >> n >> q; vi a(n + 1); forn(i, 1, n + 1)cin >> a[i]; vi diff(n + 2); while (q--) { int l, r; cin >> l >> r; diff[l] += 1; diff[r + 1] -= 1; } forn(i, 1, n + 1)diff[i] += diff[i - 1]; debug(diff); forn(i, 1, n + 1) { if (diff[i] & 1) { cout << 1 - a[i] << " "; } else cout << a[i] << " "; } cout << nl; } int32_t main() { fastnuces; //cin >> t; while (t--) { solve(); } return 0; }