/** author: shobonvip created: 2025.07.12 05:30:47 **/ #include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; vector u(m),v(m); rep(i,0,m){ cin>>u[i]>>v[i]; u[i]--;v[i]--; } int q;cin>>q; vector event(q); rep(i,0,q){ cin>>event[i]; event[i]--; } vector alive(m,true); rep(i,0,q)alive[event[i]]=false; dsu uf(n); ll ans=ll(n)*(n-1)/2; rep(i,0,m){ if(alive[i]){ if(uf.same(u[i],v[i]))continue; ans-=ll(uf.size(u[i]))*uf.size(v[i]); uf.merge(u[i],v[i]); } } vector ret(q); rrep(i,0,q){ ret[i]=ans; int x=event[i]; if(uf.same(u[x],v[x]))continue; ans-=ll(uf.size(u[x]))*uf.size(v[x]); uf.merge(u[x],v[x]); } rep(i,0,q){ cout<