#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, Q, i; cin >> N >> Q; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; vector L(Q), R(Q); for (i = 0; i != Q; ++i) cin >> L[i] >> R[i]; vector imos(N + 1, false); for (i = 0; i != Q; ++i) imos[L[i] - 1] = !imos[L[i] - 1], imos[R[i]] = !imos[R[i]]; for (i = 1; i <= N; ++i) imos[i] = imos[i] ^ imos[i - 1]; if ((A[0] == '0') ^ imos[0]) cout << '0'; else cout << '1'; for (i = 1; i != N; ++i) { if ((A[i] == '0') ^ imos[i]) cout << " 0"; else cout << " 1"; } cout << '\n'; return 0; }