#include <bits/stdc++.h>
using namespace std;
template <class T>
istream &operator>>(istream &in, vector<T> &arr) {
  for (auto &x : arr) in >> x;
  return in;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> adj(n);
  vector<long long> deg(n);
  long long ans = 0;
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    --x, --y;
    if (x > y) swap(x, y);
    adj[x].push_back(y);
    ++deg[x], ++deg[y];
  }
  for (long long i = 0; i < n; ++i) {
    ans += (((long long)adj[i].size()) * (deg[i] - ((long long)adj[i].size())));
  }
  cout << ans << '\n';
  long long q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    --x;
    ans -= (((long long)adj[x].size()) * (deg[x] - ((long long)adj[x].size())));
    for (auto y : adj[x]) {
      ans -=
          (((long long)adj[y].size()) * (deg[y] - ((long long)adj[y].size())));
      adj[y].push_back(x);
      ans +=
          (((long long)adj[y].size()) * (deg[y] - ((long long)adj[y].size())));
    }
    adj[x].clear();
    ans += (((long long)adj[x].size()) * (deg[x] - ((long long)adj[x].size())));
    cout << ans << '\n';
  }
}
