#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, q, a[maxn], d[maxn];
long long ans;
vector<int> H[maxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d %d", &u, &v);
    if (u < v) swap(u, v);
    d[u]++, d[v]++;
    H[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    for (int j : H[i]) {
      ans += H[j].size();
    }
  }
  printf("%lld\n", ans), scanf("%d", &q);
  for (int i = 1, x; i <= q; i++) {
    scanf("%d", &x);
    int sz = d[x] - H[x].size();
    for (int y : H[x]) {
      ans -= H[y].size() + sz;
      H[y].push_back(x);
      ans += d[y] - H[y].size();
    }
    H[x].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
