#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100000 + 10;
long long m, n;
vector<long long> mmp[maxn];
long long indegree[maxn], outdegree[maxn];
long long ans;
void solve(long long rt) {
  ans -= indegree[rt] * outdegree[rt];
  indegree[rt] += outdegree[rt];
  outdegree[rt] = 0;
  for (auto v : mmp[rt]) {
    ans -= outdegree[v] * indegree[v];
    mmp[v].push_back(rt);
    outdegree[v]++, indegree[v]--;
    ans += outdegree[v] * indegree[v];
  }
  mmp[rt].clear();
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 0, a, b; i < m; ++i) {
    scanf("%lld%lld", &a, &b);
    if (a > b) swap(a, b);
    mmp[a].push_back(b);
    indegree[b]++, outdegree[a]++;
  }
  for (long long i = 1; i <= n; ++i) ans += outdegree[i] * indegree[i];
  printf("%lld\n", ans);
  long long q, pos;
  scanf("%lld", &q);
  while (q--) {
    scanf("%lld", &pos);
    solve(pos);
    printf("%lld\n", ans);
  }
  return 0;
}
