1 #include<cstdio>
2 #include<cstdlib>
3 using namespace std;
4
5 #define maxn 400010
6 int father[maxn],side[maxn],next[maxn];
7 int toit[maxn],save[maxn],ans[maxn],cnt,tot,n,m;
8 bool exist[maxn],jud[maxn];
9
10 inline void init() { for (int i = 0;i < n;++i) father[i] = i;}
11
12 inline int find(int a) { if (father[a] != a) father[a] = find(father[a]); return father[a]; }
13
14 inline void add(int a,int b) { next[++cnt] = side[a]; side[a] = cnt; toit[cnt] = b; }
15
16 inline void ins(int a,int b) { add(a,b); add(b,a); }
17
18 int main()
19 {
20 freopen("1015.in","r",stdin);
21 freopen("1015.out","w",stdout);
22 scanf("%d %d",&n,&m); int i,j;
23 for (i = 1;i <= m;++i)
24 {
25 int a,b; scanf("%d %d",&a,&b);
26 ins(a,b);
27 }
28 init(); int T; scanf("%d",&T);
29 for (i = 1;i <= T;++i)
30 {
31 scanf("%d",save+i);
32 exist[save[i]] = true;
33 }
34 for (i = 0;i < n;++i) if (!exist[i])
35 for (j = side[i];j;j = next[j])
36 if (!exist[toit[j]])
37 {
38 int r1 = find(i),r2 = find(toit[j]);
39 if (r1 != r2) father[r1] = r2;
40 }
41 for (i = 0;i < n;++i) { if (!exist[i]&&!jud[find(i)]) ++tot,jud[find(i)] = true; }
42 ans[T+1] = tot;
43 for (i = T;i;--i)
44 {
45 exist[save[i]] = false; ++tot;
46 for (j = side[save[i]];j;j = next[j])
47 if (!exist[toit[j]])
48 {
49 int r1 = find(save[i]),r2 = find(toit[j]);
50 if (r1 != r2) --tot;father[r1] = r2;
51 }
52 ans[i] = tot;
53 }
54 for (i = 1;i <= T+1;++i) printf("%d\n",ans[i]);
55 fclose(stdin); fclose(stdout);
56 return 0;
57 }