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