1 type point=^node;
2 node=record
3 g:longint;
4 next:point;
5 end;
6 var
7 i,j,k,l,m,n,t:longint;
8 a:array[0..400000] of point;
9 c,b,d,e:array[0..400000] of longint;
10 p:point;
11 function getfat(x:longint):longint;inline;
12 begin
13 if x<>c[x] then
14 begin
15 c[x]:=getfat(c[x]); //orz强悍的优化
16 end;
17 exit(c[x]);
18 end;
19 function tog(x,y:longint):boolean;inline;
20 begin
21 exit(getfat(x)=getfat(y));
22 end;
23 procedure merge(x,y:longint);inline;
24 begin
25 c[getfat(x)]:=getfat(y);
26 end;
27 procedure add(x,y:longint);inline;
28 var p:point;
29 begin
30 new(p);
31 p^.g:=y;
32 p^.next:=a[x];
33 a[x]:=p;
34 end;
35 begin
36 readln(n,m);
37 for i:=1 to n do
38 begin
39 c[i]:=i;
40 a[i]:=nil;
41 end;
42 for i:=1 to m do
43 begin
44 readln(j,k);
45 add(j+1,k+1);add(k+1,j+1);
46 end;
47 fillchar(b,sizeof(b),0);
48 readln(t);
49 for i:=1 to t do
50 begin
51 readln(d[i]);
52 d[i]:=d[i]+1;
53 b[d[i]]:=1;
54 end;
55 l:=n;
56 for i:=1 to n do
57 begin
58 if b[i]=0 then
59 begin
60 p:=a[i];
61 while p<>nil do
62 begin
63 if b[p^.g]=0 then
64 begin
65 if not(tog(i,p^.g)) then
66 begin
67 dec(l);merge(i,p^.g);
68 end;
69 end;
70 p:=p^.next;
71 end;
72 end;
73 end;
74 e[t+1]:=l;
75 for i:=t downto 1 do
76 begin
77 b[d[i]]:=0;
78 p:=a[d[i]];
79 while p<>nil do
80 begin
81 if b[p^.g]=0 then
82 begin
83 if not(tog(d[i],p^.g)) then
84 begin
85 merge(d[i],p^.g);
86 dec(l);
87 end;
88 end;
89 p:=p^.next;
90 end;
91 e[i]:=l;
92 end;
93 for i:=1 to t+1 do writeln(e[i]-i+1);
94 end.