#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef int ll;
const ll MAX = 1e5 + 20;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
ll n, m, q, in[MAX], out[MAX];
vector<ll> adj[MAX];
int main() {
  cin >> n >> m;
  ll u, v;
  for (ll i = 0; i < (ll)m; i++) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    adj[u].push_back(v);
    in[u]++, out[v]++;
  }
  long long cur = 0;
  for (ll i = 1; i < (ll)n + 1; i++) cur += 1LL * in[i] * out[i];
  cout << cur << endl;
  cin >> q;
  while (q--) {
    cin >> u;
    cur -= 1LL * in[u] * out[u];
    for (ll v : adj[u]) {
      cur -= 1LL * in[v] * out[v];
      out[u]++, in[u]--;
      in[v]++, out[v]--;
      cur += 1LL * in[v] * out[v];
      adj[v].push_back(u);
    }
    adj[u].clear();
    cout << cur << endl;
  }
  return 0;
}
