#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int n, m, q;
int deg[MAXN];
vector<int> in_edges[MAXN];
long long ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
    in_edges[min(u, v)].push_back(max(u, v));
  }
  for (int u = 1; u <= n; u++) {
    ans += 1LL * in_edges[u].size() * (deg[u] - (int)in_edges[u].size());
  }
  cout << ans << endl;
  cin >> q;
  while (q--) {
    int node;
    cin >> node;
    long long old_paths =
        1LL * in_edges[node].size() * (deg[node] - (int)in_edges[node].size());
    long long new_paths = 0;
    for (auto v : in_edges[node]) {
      old_paths +=
          1LL * in_edges[v].size() * (deg[v] - (int)in_edges[v].size());
      in_edges[v].push_back(node);
      new_paths +=
          1LL * in_edges[v].size() * (deg[v] - (int)in_edges[v].size());
    }
    in_edges[node].clear();
    ans = ans - old_paths + new_paths;
    cout << ans << endl;
  }
  return 0;
}
