1 #include <cstdio>
2 #include <cstring>
3 #include <cstdlib>
4 #include <cmath>
5 #include <deque>
6 #include <vector>
7 #include <queue>
8 #include <iostream>
9 #include <algorithm>
10 #include <map>
11 #include <set>
12 #include <ctime>
13 using namespace std;
14 typedef long long LL;
15 typedef double DB;
16 #define For(i, s, t) for(int i = (s); i <= (t); i++)
17 #define Ford(i, s, t) for(int i = (s); i >= (t); i--)
18 #define MIT (2147483647)
19 #define INF (1000000001)
20 #define MLL (1000000000000000001LL)
21 #define sz(x) ((int) (x).size())
22 #define clr(x, y) memset(x, y, sizeof(x))
23 #define puf push_front
24 #define pub push_back
25 #define pof pop_front
26 #define pob pop_back
27 #define ft first
28 #define sd second
29 #define mk make_pair
30 inline void SetIO(string Name) {
31 string Input = Name+".in",
32 Output = Name+".out";
33 freopen(Input.c_str(), "r", stdin),
34 freopen(Output.c_str(), "w", stdout);
35 }
36
37 const int N = 400010, M = 200010;
38 int n, m, Fa[N], Opt, Dat[N];
39 int First[N], To[M<<1], Next[M<<1], Tot;
40 bool Destroy[N];
41 int Stack[N], Len, Cnt, Ans[N];
42
43 inline void Insert(int u, int v) {
44 Tot++;
45 To[Tot] = v, Next[Tot] = First[u];
46 First[u] = Tot;
47 }
48
49 inline void Input() {
50 scanf("%d%d", &n, &m);
51 For(i, 1, m) {
52 int u, v;
53 scanf("%d%d", &u, &v);
54 u++, v++;
55 Insert(u, v), Insert(v, u);
56 }
57 scanf("%d", &Opt);
58 For(i, 1, Opt) {
59 scanf("%d", &Dat[i]);
60 Dat[i]++;
61 }
62 }
63
64 inline int Find(int x) {
65 Len = 0;
66 while(x != Fa[x]) {
67 Stack[++Len] = x;
68 x = Fa[x];
69 }
70
71 Ford(i, Len, 1) Fa[Stack[i]] = x;
72 return x;
73 }
74
75 inline void Merge(int u, int v) {
76 u = Find(u), v = Find(v);
77 if(u != v) {
78 Cnt--;
79 Fa[u] = v;
80 }
81 }
82
83 inline void Solve() {
84 For(i, 1, Opt) Destroy[Dat[i]] = 1;
85
86 Cnt = n-Opt;
87 For(i, 1, n) Fa[i] = i;
88 For(i, 1, n)
89 if(!Destroy[i]) {
90 for(int v, Tab = First[i]; Tab; Tab = Next[Tab])
91 if(!Destroy[v = To[Tab]]) Merge(i, v);
92 }
93
94 Ford(i, Opt, 1) {
95 Ans[i] = Cnt;
96 Cnt++;
97 int u = Dat[i];
98 Destroy[u] = 0;
99 for(int v, Tab = First[u]; Tab; Tab = Next[Tab])
100 if(!Destroy[v = To[Tab]]) Merge(u, v);
101 }
102
103 Ans[0] = Cnt;
104 For(i, 0, Opt) printf("%d\n", Ans[i]);
105 }
106
107 int main() {
108 SetIO("1015");
109 Input();
110 Solve();
111 return 0;
112 }