#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 100;
vector<long long> rg[N];
long long g[N];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (m); ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    if (u < v) swap(u, v);
    g[u]++;
    rg[v].push_back(u);
  }
  long long ans = 0;
  for (long long i = (0); i < (n); ++i) {
    ans += g[i] * (long long)(rg[i].size());
  }
  cout << ans << "\n";
  long long q;
  cin >> q;
  while (q--) {
    long long v;
    cin >> v;
    --v;
    ans -= g[v] * (long long)(rg[v].size());
    for (long long u : rg[v]) {
      ans -= g[u] * (long long)(rg[u].size());
      g[u]--;
      rg[u].push_back(v);
      g[v]++;
      ans += g[u] * (long long)(rg[u].size());
    }
    rg[v].clear();
    cout << ans << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
