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