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