#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> deg;
long long get(int u) {
  return (1LL * g[u].size()) * (1LL * deg[u] - 1LL * g[u].size());
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  g.assign(n + 1, vector<int>());
  deg.assign(n + 1, 0);
  for (int i = 0, a, b; i < m; ++i) {
    scanf("%d%d", &a, &b);
    g[min(a, b)].push_back(max(a, b));
    ++deg[a];
    ++deg[b];
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += get(i);
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  for (int i = 0, a; i < q; ++i) {
    scanf("%d", &a);
    ans -= get(a);
    while (g[a].size() > 0) {
      int b = g[a].back();
      g[a].pop_back();
      ans -= get(b);
      g[b].push_back(a);
      ans += get(b);
    }
    printf("%lld\n", ans);
  }
}
