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