1 #include<stdio.h>
2 using namespace std;
3 int a[400001],b[400001],c[400001],pre[400001],head[400001],next[400001],to[400001],tot,n,m,k;
4 bool des[400001];
5 int ans[400001];
6 int getf(int x) {
7 int r=x;
8 while(r!=pre[r]) r=pre[r];
9 int i=x,j;
10 while(i!=r) {
11 j=pre[i];
12 pre[i]=r;
13 i=j;
14 }
15 return r;
16 }
17 void addedge(int u,int v) {
18 ++tot;
19 to[tot]=v;
20 next[tot]=head[u];
21 head[u]=tot;
22 }
23 int main() {
24 scanf("%d%d",&n,&m);
25 for (int i=1;i<=n;++i) pre[i]=i;
26 for (int i=1;i<=m;++i) {
27 scanf("%d%d",&a[i],&b[i]);
28 a[i]++,b[i]++;
29 addedge(a[i],b[i]);
30 addedge(b[i],a[i]);
31 }
32 scanf("%d",&k);
33 for (int i=1;i<=k;++i) {
34 scanf("%d",&c[i]);
35 c[i]++;
36 des[c[i]]=1;
37 }
38 int ansx=n-k;
39 for (int i=1;i<=n;++i)
40 if(!des[i]) {
41 int f1=getf(i);
42 for (int j=head[i];j;j=next[j]) {
43 if(!des[to[j]]) {
44 int f2=getf(to[j]);
45 if(f1!=f2) pre[f2]=f1, ansx--;
46 }
47 }
48 }
49 ans[k+1]=ansx;
50 for (int i=k;i>=1;--i) {
51 ++ansx;
52 int f1=c[i];
53 for (int j=head[c[i]];j;j=next[j])
54 if(!des[to[j]]) {
55 int f2=getf(to[j]);
56 if(f1!=f2) pre[f2]=f1,--ansx;
57 }
58 ans[i]=ansx;
59 des[c[i]]=0;
60 }
61 for (int i=1;i<=k+1;++i) printf("%d\n",ans[i]);
62 return 0;
63 }