#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  vector<long> parents[n + 1];
  vector<long> inp(n + 1, 0);
  for (long i = 0; i < m; i++) {
    long a, b;
    cin >> a >> b;
    long mx = max(a, b);
    long mn = min(a, b);
    parents[mn].push_back(mx);
    inp[a] += 1;
    inp[b] += 1;
  }
  long long res = 0;
  for (long i = 1; i <= n; i++) {
    res += parents[i].size() * (inp[i] - parents[i].size());
  }
  cout << res << endl;
  long q;
  cin >> q;
  for (long i = 0; i < q; i++) {
    long v;
    cin >> v;
    res -= parents[v].size() * (inp[v] - parents[v].size());
    for (const auto& p : parents[v]) {
      res -= parents[p].size() * (inp[p] - parents[p].size());
      parents[p].push_back(v);
      res += parents[p].size() * (inp[p] - parents[p].size());
    }
    parents[v].clear();
    cout << res << endl;
  }
  return 0;
}
