#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;
const int N = 1e5 + 100;
int n, m;
int U[N], V[N];
vi in[N];
ll ans;
int deg[N];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    deg[u]++;
    deg[v]++;
    if (u > v) {
      in[v].push_back(i);
      U[i] = u;
      V[i] = v;
    } else {
      in[u].push_back(i);
      U[i] = v;
      V[i] = u;
    }
  }
  for (int i = 0; i < n; i++) {
    ans += 1LL * (int)((in[i]).size()) * (deg[i] - (int)((in[i]).size()));
  }
  cout << ans << '\n';
  int q;
  cin >> q;
  while (q--) {
    int v;
    cin >> v;
    --v;
    int rem = (int)((in[v]).size());
    for (int i : in[v]) {
      int u = U[i];
      ans -= (deg[v] - rem) + (int)((in[u]).size());
      in[u].push_back(i);
      rem--;
      ans += rem + (deg[u] - (int)((in[u]).size()));
      swap(U[i], V[i]);
    }
    in[v].clear();
    cout << ans << '\n';
  }
}
