#include<bits/stdc++.h> #define fst first #define snd second #define re register
usingnamespace std;
typedef pair<int,int> pii; constint N = 5e5 + 10; int n,m,e,q,sum; int f[N],sz[N],del[N],ans[N]; bool st[N],vis[N]; pii g[N];
inlineintread(){ int r = 0,w = 1; char c = getchar(); while (c < '0' || c > '9'){ if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9'){ r = (r << 3) + (r << 1) + (c ^ 48); c = getchar(); } return r * w; }
inlinevoidmerge(int x,int y){ int a = find(x); int b = find(y); if (!st[a] && st[b]){ st[a] = true; sum += sz[a]; } elseif (st[a] && !st[b]){ st[b] = true; sum += sz[b]; } if (a == b) return; f[a] = b; sz[b] += sz[a]; }
intmain(){ n = read(); m = read(); e = read(); for (re int i = 1;i <= e;i++){ g[i].fst = read(); g[i].snd = read(); } for (re int i = 1;i <= n;i++) sz[i] = 1; for (re int i = 1;i <= n + m;i++) f[i] = i; for (re int i = n + 1;i <= n + m;i++) st[i] = true;//所有发电站都是有电的 q = read(); for (re int i = 1;i <= q;i++){ del[i] = read(); vis[del[i]] = true; } for (re int i = 1;i <= e;i++){ if (!vis[i]) merge(g[i].fst,g[i].snd); } for (re int i = q;i;i--){ ans[i] = sum; merge(g[del[i]].fst,g[del[i]].snd); } for (re int i = 1;i <= q;i++) printf("%d\n",ans[i]); return0; }