#include <cstdio>
const int maxn = 400000 + 10, maxm = 200000 + 10;
int n, m, k;
struct Edge{
int to, next;
Edge(){}
Edge(int _t, int _n): to(_t), next(_n){}
}e[maxm << 1];
int fir[maxn] = {0}, cnt = 0;
inline void ins(int u, int v){
e[++cnt] = Edge(v, fir[u]); fir[u] = cnt;
e[++cnt] = Edge(u, fir[v]); fir[v] = cnt;
}
int fuck[maxn], fff[maxn];
bool state[maxn] = {false};
int fa[maxn];
int Find(int x){
return x == fa[x] ? x : fa[x] = Find(fa[x]);
}
int main(){
scanf("%d %d", &n, &m);
for(int u, v, i = 1; i <= m; i++){
scanf("%d %d", &u, &v);
ins(u, v);
}
int k;
scanf("%d", &k);
for(int i = 1; i <= k; i++){
scanf("%d", fuck + i);
state[fuck[i]] = true;
}
for(int i = 0; i < n; i++) fa[i] = i;
for(int u = 0; u < n; u++){
if(state[u]) continue;
for(int v, i = fir[u]; i; i = e[i].next){
v = e[i].to;
if(state[v]) continue;
fa[Find(u)] = Find(v);
}
}
int ans = 0;
for(int i = 0; i < n; i++)
if(!state[i] && Find(i) == i) ans++;
for(int i = k; i; i--){
fff[i] = ans;
state[fuck[i]] = false;
ans++;
for(int v, j = fir[fuck[i]]; j; j = e[j].next){
v = e[j].to;
if(state[v]) continue;
if(Find(v) != Find(fuck[i])){
ans--;
fa[Find(v)] = Find(fuck[i]);
}
}
}
printf("%d\n", ans);
for(int i = 1; i <= k; i++)
printf("%d\n", fff[i]);
return 0;
}