#include <bits/stdc++.h>
using namespace std;
vector<int> G[100050];
long long cnt[100050];
long long xiao[100050];
pair<int, int> edge[100060];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[i] = pair<int, int>(u, v);
    if (u < v) {
      G[u].push_back(v);
      xiao[v]++;
    } else {
      G[v].push_back(u);
      xiao[u]++;
    }
    cnt[v]++;
    cnt[u]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (cnt[i] - xiao[i]) * xiao[i];
  }
  cout << ans << "\n";
  int q;
  cin >> q;
  while (q--) {
    int id;
    scanf("%d", &id);
    for (auto to : G[id]) {
      ans = ans - (cnt[to] - xiao[to]) * xiao[to] +
            (cnt[to] - xiao[to] + 1) * (xiao[to] - 1);
      G[to].push_back(id);
      xiao[to]--;
    }
    G[id].clear();
    ans = ans - (cnt[id] - xiao[id]) * xiao[id];
    xiao[id] = cnt[id];
    printf("%lld\n", ans);
  }
  return 0;
}
