1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #define rep(i,l,r) for(int i=l; i<=r; i++)
5 #define clr(x,y) memset(x,y,sizeof(x))
6 #define travel(x) for(int i=last[x]; i; i=edge[i].pre)
7 using namespace std;
8 const int INF = 0x3f3f3f3f;
9 const int maxn = 400010;
10 struct Edge{
11 int pre,to;
12 }edge[maxn];
13 int m,n,x,y,k,tot=0,cnt=0,last[maxn],a[maxn],ans[maxn],fa[maxn];
14 bool attack[maxn],added[maxn];
15 inline int read(){
16 int ans = 0, f = 1;
17 char c = getchar();
18 while (!isdigit(c)){
19 if (c == ‘-‘) f = -1;
20 c = getchar();
21 }
22 while (isdigit(c)){
23 ans = ans * 10 + c - ‘0‘;
24 c = getchar();
25 }
26 return ans * f;
27 }
28 inline void addedge(int x,int y){
29 edge[++tot].pre = last[x];
30 edge[tot].to = y;
31 last[x] = tot;
32 }
33 int getfa(int x){
34 return fa[x] == x ? x : fa[x] = getfa(fa[x]);
35 }
36 inline void add(int x){
37 cnt++;
38 int p = getfa(x), q;
39 travel(x) if (added[edge[i].to]){
40 q = getfa(edge[i].to);
41 if (p != q){
42 fa[q] = p;
43 cnt--;
44 }
45 }
46 added[x] = 1;
47 }
48 int main(){
49 n = read(); m = read(); clr(last,0);
50 rep(i,1,m){
51 x = read(); y = read();
52 addedge(x,y); addedge(y,x);
53 }
54 rep(i,0,n-1) fa[i] = i; clr(added,0);
55 k = read();
56 rep(i,1,k) a[i] = read(), attack[a[i]] = 1;
57 rep(i,0,n-1) if (!attack[i]) add(i);
58 ans[k+1] = cnt;
59 for(int i=k; i>=1; i--){
60 add(a[i]);
61 ans[i] = cnt;
62 }
63 rep(i,1,k+1) printf("%d\n",ans[i]);
64 return 0;
65 }