#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n, m;
vector<int> g[N];
int q, cd[N];
long long ans;
int main() {
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; i++) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    g[u].push_back(v);
    cd[v]++;
  }
  for (int i = 1; i <= n; i++) ans += 1ll * g[i].size() * cd[i];
  cout << ans << endl;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    ans -= 1ll * g[t].size() * cd[t];
    for (auto i : g[t]) {
      ans -= 1ll * g[i].size() * cd[i];
      cd[i]--;
      g[i].push_back(t);
      cd[t]++;
      ans += 1ll * g[i].size() * cd[i];
    }
    g[t].clear();
    cout << ans << endl;
  }
  return 0;
}
