#include <bits/stdc++.h>
using namespace std;
vector<long long> deg;
vector<vector<long long>> in;
long long prod(long long i) { return in[i].size() * (deg[i] - in[i].size()); }
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n, m, a, b, q;
  long long ans = 0;
  cin >> n >> m;
  in.resize(n + 1);
  deg.resize(n + 1);
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    if (a < b) swap(a, b);
    in[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  for (long long i = 1; i <= n; i++) ans += prod(i);
  cout << ans << '\n';
  cin >> q;
  while (q--) {
    cin >> a;
    ans -= prod(a);
    for (auto &i : in[a]) {
      ans -= prod(i);
      in[i].push_back(a);
      ans += prod(i);
    }
    in[a].resize(0);
    cout << ans << '\n';
  }
  return 0;
}
