#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, m, indeg[maxn], outdeg[maxn];
vector<int> g[maxn];
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if (u < v) swap(u, v);
    g[v].push_back(u);
    indeg[v]++;
    outdeg[u]++;
  }
  for (int i = 1; i <= n; i++) ans += 1LL * indeg[i] * outdeg[i];
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &u);
    ans -= 1LL * indeg[u] * outdeg[u];
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i];
      ans -= 1LL * indeg[v] * outdeg[v];
      outdeg[v]--;
      indeg[v]++;
      g[v].push_back(u);
      ans += 1LL * indeg[v] * outdeg[v];
    }
    outdeg[u] += indeg[u];
    indeg[u] = 0;
    g[u].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
