1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cstdlib>
5 #include<cmath>
6 #include<algorithm>
7 #include<ctime>
8 using namespace std;
9 int n,m,d,len,tot,q[400100],a[400100],f[400100],vis[400100],used[400100],ans[400100];
10 struct node{int y,next;}e[400100];
11 inline int read()
12 {
13 int x=0,f=1; char ch=getchar();
14 while(!isdigit(ch)) {if(ch==‘-‘) f=-1; ch=getchar();}
15 while(isdigit(ch)) {x=x*10+ch-‘0‘; ch=getchar();}
16 return x*f;
17 }
18 void insert(int xx,int yy)
19 {
20 e[++len].next=a[xx];
21 a[xx]=len;
22 e[len].y=yy;
23 }
24 int find(int x)
25 {return f[x]==x?x:f[x]=find(f[x]);}
26 void add(int x)
27 {
28 int pp=find(x),qq;
29 for(int i=a[x];i;i=e[i].next)
30 {
31 if(used[e[i].y])
32 {
33 qq=find(e[i].y);
34 if(pp!=qq) {tot--; f[qq]=pp;}
35 }
36 }
37 }
38 int main()
39 {
40 n=read(); m=read();
41 for(int i=0;i<n;i++) f[i]=i;
42 for(int i=1;i<=m;i++)
43 {
44 int x=read(),y=read();
45 insert(x,y);
46 insert(y,x);
47 }
48 d=read();
49 for(int i=1;i<=d;i++)
50 {
51 q[i]=read();
52 vis[q[i]]=1;
53 }
54 for(int i=0;i<n;i++)
55 if(!vis[i])
56 {
57 tot++;
58 add(i);
59 used[i]=1;
60 }
61 ans[d+1]=tot;
62 for(int i=d;i>0;i--)
63 {
64 tot++;
65 add(q[i]);
66 used[q[i]]=1;
67 ans[i]=tot;
68 }
69 for(int i=1;i<=d+1;i++) printf("%d\n",ans[i]);
70 return 0;
71 }