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