#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n, m, sz;
bool closed[N];
vector <int> adj[N];
void file(string fl, string in, string out) {
cin.tie(0)->sync_with_stdio(0);
freopen((fl + "." + in).c_str(), "r", stdin);
freopen((fl + "." + out).c_str(), "w", stdout);
return;
}
bool BFS() {
queue <int> q;
int cnt = 0;
bool vst[n + 10] = {0};
for (int u = 1; u <= n; u++) {
if (!closed[u]) {
vst[u] = 1;
q.push(u);
break;
}
}
while (q.size()) {
int u = q.front(); q.pop();
cnt++;
for (int v : adj[u]) {
if (!closed[v] && !vst[v]) {
vst[v] = 1;
q.push(v);
}
}
}
return (cnt == sz);
}
int main() {
file("Closing", "in", "out");
cin >> n >> m;
sz = n;
for (int u, v, i = 1; i <= m; i++) {
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int u, i = 1; i <= n; i++) {
cin >> u;
cout << (BFS() ? "YES" : "NO") << "\n";
closed[u] = 1;
sz--;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAzMDEwOwoKaW50IG4sIG0sIHN6Owpib29sIGNsb3NlZFtOXTsKdmVjdG9yIDxpbnQ+IGFkaltOXTsKCnZvaWQgZmlsZShzdHJpbmcgZmwsIHN0cmluZyBpbiwgc3RyaW5nIG91dCkgewoJY2luLnRpZSgwKS0+c3luY193aXRoX3N0ZGlvKDApOwoJZnJlb3BlbigoZmwgKyAiLiIgKyBpbikuY19zdHIoKSwgInIiLCBzdGRpbik7CglmcmVvcGVuKChmbCArICIuIiArIG91dCkuY19zdHIoKSwgInciLCBzdGRvdXQpOwoJcmV0dXJuOwp9Cgpib29sIEJGUygpIHsKCXF1ZXVlIDxpbnQ+IHE7CglpbnQgY250ID0gMDsKCWJvb2wgdnN0W24gKyAxMF0gPSB7MH07Cglmb3IgKGludCB1ID0gMTsgdSA8PSBuOyB1KyspIHsKCQlpZiAoIW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