#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const ll LINF = 4611686018427387903;
const int MOD = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<ll> out(n + 1);
  vector<vector<int>> inn(n + 1);
  ll ans = 0;
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    inn[a].push_back(b);
    out[b]++;
  }
  for (int i = 1; i <= n; i++) ans += out[i] * ll(inn[i].size());
  cout << ans << '\n';
  int q;
  cin >> q;
  while (q--) {
    int w;
    cin >> w;
    ans -= out[w] * ll(inn[w].size());
    out[w] += inn[w].size();
    for (int a : inn[w]) {
      ans -= out[a] * ll(inn[a].size());
      out[a]--;
      inn[a].push_back(w);
      ans += out[a] * ll(inn[a].size());
    }
    inn[w].clear();
    cout << ans << '\n';
  }
  return 0;
}
