#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ofstream fout ("closing.out");
ifstream fin ("closing.in");
int N, M;
int x, y;
int open, found, c;
vi adj[3001];
vi close;
bool closed[3001];
bool vis[3001];
void dfs(int v) {
if (vis[v] || closed[v]) return;
vis[v] = true;
for (auto const& w: adj[v]){
if (!closed[w])
dfs(w);
}
}
int main() {
fin >> N >> M;
for (int i = 0; i < M; i++) {
fin >> x >> y;
adj[x].pb(y);
adj[y].pb(x);
}
for (int i = 0; i < M; i++) {
fin >> x;
close.pb(x);
}
open = N;
for (int i = 0; i < N; i++) {
memset(vis, 0, sizeof vis);
c = 0;
for (int j = 1; j <= N; j++) {
if (!vis[j] && !closed[j]) {
dfs(j);
c++;
}
}
if (c == 1)
fout << "YES" << endl;
else
fout << "NO" << endl;
if (i < N - 1)
closed[close[i]] = true;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKCnR5cGVkZWYgbG9uZyBsb25nIGludCBsbDsKdHlwZWRlZiBwYWlyPGludCwgaW50PiBwaWk7CnR5cGVkZWYgdmVjdG9yPGludD4gdmk7CnR5cGVkZWYgdmVjdG9yPHBpaT4gdmlpOwoKb2ZzdHJlYW0gZm91dCAoImNsb3Npbmcub3V0Iik7Cmlmc3RyZWFtIGZpbiAoImNsb3NpbmcuaW4iKTsKCmludCBOLCBNOwppbnQgeCwgeTsKaW50IG9wZW4sIGZvdW5kLCBjOwp2aSBhZGpbMzAwMV07CnZpIGNsb3NlOwoKYm9vbCBjbG9zZWRbMzAwMV07CmJvb2wgdmlzWzMwMDFdOwoKdm9pZCBkZnMoaW50IHYpIHsKICBpZiAodmlzW3ZdIHx8IGNsb3NlZFt2XSkgcmV0dXJuOwogIHZpc1t2XSA9IHRydWU7CgogIGZvciAoYXV0byBjb25zdCYgdzogYWRqW3ZdKXsKICAgIGlmICghY2xvc2VkW3ddKQogICAgICBkZnModyk7CiAgfSAKfQoKaW50IG1haW4oKSB7CiAgZmluID4+IE4gPj4gTTsKICBmb3IgKGludCBpID0gMDsgaSA8IE07IGkrKykgewogICAgZmluID4+IHggPj4geTsgCiAgICBhZGpbeF0ucGIoeSk7CiAgICBhZGpbeV0ucGIoeCk7CiAgfQoKICBmb3IgKGludCBpID0gMDsgaSA8IE07IGkrKykgewogICAgZmluID4+IHg7CiAgICBjbG9zZS5wYih4KTsKICB9CgogIG9wZW4gPSBOOwogIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKSB7CiAgICBtZW1zZXQodmlzLCAwLCBzaXplb2YgdmlzKTsKICAgIGMgPSAwOwoKICAgIGZvciAoaW50IGogPSAxOyBqIDw9IE47IGorKykgewogICAgICBpZiAoIXZpc1tqXSAmJiAhY2xvc2VkW2pdKSB7CiAgICAgICAgZGZzKGopOwogICAgICAgIGMrKzsKICAgICAgfQogICAgfQoKICAgIGlmIChjID09IDEpCiAgICAgIGZvdXQgPDwgIllFUyIgPDwgZW5kbDsKICAgIGVsc2UKICAgICAgZm91dCA8PCAiTk8iIDw8IGVuZGw7CgogICAgaWYgKGkgPCBOIC0gMSkKICAgICAgY2xvc2VkW2Nsb3NlW2ldXSA9IHRydWU7CiAgfQoKICByZXR1cm4gMDsKfQ==