#include <bits/stdc++.h>
using namespace std;
vector<long long> brag[200005];
long long out[200005];
long long in[200005];
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    brag[a].push_back(b);
    out[b]++;
    in[a]++;
  }
  long long ans = 0;
  for (long long i = 1; i < n + 1; i++) {
    ans += out[i] * in[i];
  }
  cout << ans << "\n";
  long long q;
  cin >> q;
  while (q--) {
    long long i;
    cin >> i;
    ans -= out[i] * in[i];
    for (auto j : brag[i]) {
      ans -= out[j] * in[j];
      out[j]--;
      in[j]++;
      ans += out[j] * in[j];
      brag[j].push_back(i);
    }
    brag[i].clear();
    out[i] = out[i] + in[i];
    in[i] = 0;
    cout << ans << "\n";
  }
  return 0;
}
