#include <bits/stdc++.h>
using namespace std;
const int MX = 123456;
const long long MD = 1000000007;
long long V, E;
long long deg[MX];
vector<long long> infer[MX];
int32_t main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> V >> E;
  long long ans = 0;
  for (long long i = 0; i < E; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    deg[u]++;
    deg[v]++;
    infer[min(u, v)].push_back(max(u, v));
  }
  for (long long i = 0; i < V; i++) {
    ans += (deg[i] - ((long long)(infer[i]).size())) *
           ((long long)(infer[i]).size());
  }
  cout << ans << endl;
  long long Q;
  cin >> Q;
  for (long long _q = 0; _q < Q; _q++) {
    long long u;
    cin >> u;
    u--;
    for (auto v : infer[u]) {
      infer[v].push_back(u);
      long long x = ((long long)(infer[v]).size());
      ans += deg[v] - 2 * x + 1;
    }
    ans -= (deg[u] - ((long long)(infer[u]).size())) *
           ((long long)(infer[u]).size());
    infer[u].clear();
    cout << ans << endl;
  }
  return 0;
}
