C++#include "iostream"
#include "queue"
#include "cmath"
#include "algorithm"
#include "vector"
#include "set"
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
template <class T> inline void gmax (T &x, T y) {if (x < y) x = y;}
template <class T> inline void gmin (T &x, T y) {if (x > y) x = y;}
template <class T> inline void gadd (T &x, T y) {x = (x + y) % mod;}
template <class T> inline void gmul (T &x, T y) {x = x * y % mod;}
#define pb push_back
#define fi first
#define se second
int n, q; int s[N], a[N]; std :: set <int> p;
std :: set <int> ill;
signed main () {
std :: cin.tie (0) -> std :: ios :: sync_with_stdio (false);
std :: cin >> n >> q; for (int i = 1; i <= n; ++i) std :: cin >> a[i];
for (int i = 1; i <= q; ++i) {
int x; std :: cin >> x; s[x] ^= 1; if (s[x]) {
if (a[x]) { ill.insert (x);
for (auto u : p) {
a[u] = 1; ill.insert (u);
} p.clear ();
} else {
if (!ill.size ()) p.insert (x);
else a[x] = 1, ill.insert (x);
}
} else {
if (a[x]) {
ill.erase (x);
} else {
p.erase (x);
}
}
}
for (int i = 1; i <= n; ++i) {
std :: cout << a[i] << ' ';
}
return 0;
}