1 program hehe;
2 type
3 edge=record
4 q,z,next:longint;
5 end;
6 var
7 n,m,q,i,j,k,cnt:longint;
8 p,pd:array[0..500000] of boolean;
9 e:array[0..500000] of edge;
10 ans,c,first,f,d:array[0..500000] of longint;
11
12 function find(a:longint):longint;
13 begin
14 if f[a]=a then exit(a);
15 f[a]:=find(f[a]);
16 exit(f[a]);
17 end;
18
19 begin
20 fillchar(first,sizeof(first),255);
21 fillchar(e,sizeof(e),255);
22 fillchar(p,sizeof(p),true);
23 read(n,m);
24 for i:=0 to n-1 do
25 f[i]:=i;
26 for i:=1 to m do
27 begin
28 read(j,k);
29 if first[j]=-1 then
30 first[j]:=i;
31 e[i].q:=j;
32 e[i].z:=k;
33 e[c[j]].next:=i;
34 c[j]:=i;
35 if first[k]=-1 then
36 first[k]:=i+m;
37 e[i+m].q:=j;
38 e[i+m].z:=k;
39 e[c[k]].next:=i+m;
40 c[k]:=i+m;
41 end;
42 read(q);
43 for i:=1 to q do
44 begin
45 read(d[q-i+1]);
46 p[d[q-i+1]]:=false;
47 end;
48 for i:=0 to n-1 do
49 if p[i] then inc(cnt);
50 for i:=0 to n-1 do
51 if p[i] then
52 begin
53 k:=first[i];
54 while k<>-1 do
55 begin
56 if (p[e[k].q])and(p[e[k].z]) then
57 if find(e[k].q)<>find(e[k].z) then
58 begin
59 f[find(e[k].q)]:=find(e[k].z);
60 dec(cnt);
61 end;
62 k:=e[k].next;
63 end;
64 end;
65 ans[0]:=cnt;
66 for i:=1 to q do
67 begin
68 inc(cnt);
69 p[d[i]]:=true;
70 k:=first[d[i]];
71 while k<>-1 do
72 begin
73 if (p[e[k].q])and(p[e[k].z]) then
74 if find(e[k].q)<>find(e[k].z) then
75 begin
76 f[find(e[k].q)]:=find(e[k].z);
77 dec(cnt);
78 end;
79 k:=e[k].next;
80 end;
81 ans[q-i+1]:=cnt;
82 end;
83 for i:=1 to q do
84 writeln(ans[i]);
85 writeln(ans[0]);
86 end.