#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int cnt[maxn];
vector<int> g[maxn];
long long cal(int i) { return (cnt[i] - g[i].size()) * g[i].size(); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    g[u].push_back(v);
    cnt[u]++, cnt[v]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += cal(i);
  int q;
  cin >> q;
  cout << ans << endl;
  while (q--) {
    int x;
    cin >> x;
    ans -= cal(x);
    for (auto i : g[x]) {
      ans -= cal(i);
      g[i].push_back(x);
      ans += cal(i);
      g[x].clear();
    }
    cout << ans << endl;
  }
  return 0;
}
