#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
vector<long long> in[100010];
long long n, m, q, deg[100010];
long long ans;
long long get_ans(long long i) {
  return in[i].size() * (deg[i] - in[i].size());
}
int main() {
  cin >> n >> m;
  for (long long i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    in[u].push_back(v);
    deg[u]++, deg[v]++;
  }
  for (long long i = 1; i <= n; ++i) ans += get_ans(i);
  cout << ans << endl;
  cin >> q;
  while (q--) {
    long long u;
    cin >> u;
    ans -= in[u].size() * (deg[u] - in[u].size());
    for (long long i = 0; i < in[u].size(); ++i)
      ans -= get_ans(in[u][i]), in[in[u][i]].push_back(u),
          ans += get_ans(in[u][i]);
    in[u].clear();
    cout << ans << endl;
  }
  return 0;
}
