#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double eps = 1e-6;
const int INF32 = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int mod2 = 998244853;
const int N = 1e5 + 5;
const int sz = (1 << 20);
long long in[N], out[N];
vector<int> g[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0, u, v; i < m; ++i) {
    cin >> u >> v;
    if (v > u) swap(u, v);
    ++in[v], ++out[u];
    g[v].emplace_back(u);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += in[i] * out[i];
  cout << ans << endl;
  int q;
  cin >> q;
  while (q--) {
    cin >> n;
    ans -= in[n] * out[n];
    for (int i : g[n]) {
      --out[i];
      ans += out[i] - in[i];
      ++in[i];
      g[i].emplace_back(n);
    }
    out[n] += in[n];
    in[n] = 0;
    g[n].clear();
    cout << ans << endl;
  }
  return 0;
}
