#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
const int oo = 0x3f3f3f3f;
const ll OO = ll(oo) * oo;
const int N = 100005;
vector<vi> in;
int deg[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  in.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
    if (v > u) swap(u, v);
    in[v].emplace_back(u);
  }
  ll ans = 0;
  for (int i = 1; i < n + 1; i++) {
    ans += ll(in[i].size()) * ll(deg[i] - in[i].size());
  }
  cout << ans << '\n';
  int q;
  cin >> q;
  while (q--) {
    int u;
    cin >> u;
    ans -= ll(in[u].size()) * ll(deg[u] - in[u].size());
    for (int v : in[u]) {
      ans -= ll(in[v].size()) * ll(deg[v] - in[v].size());
      in[v].emplace_back(u);
      ans += ll(in[v].size()) * ll(deg[v] - in[v].size());
    }
    in[u] = {};
    cout << ans << '\n';
  }
  return 0;
}
