#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> v(n + 1);
  vector<int> in(n + 1), out(n + 1);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    v[x].emplace_back(y);
    in[y]++, out[x]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += 1LL * in[i] * out[i];
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    ans -= 1LL * in[x] * out[x];
    for (auto it : v[x]) {
      v[it].emplace_back(x);
      ans += 1LL * (in[it] - 1) * (out[it] + 1) - 1LL * in[it] * out[it];
      in[x]++, out[x]--, in[it]--, out[it]++;
    }
    v[x].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
