#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100100;
int n, m;
int outdeg[MAX_N];
vector<int> frm[MAX_N];
long long getVal(int u) {
  return (long long)outdeg[u] * (long long)(int)frm[u].size();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (u > v) swap(u, v);
    outdeg[v]++;
    frm[u].push_back(v);
  }
  int q;
  cin >> q;
  long long cur = 0;
  for (int i = 0; i < n; i++) cur += getVal(i);
  cout << cur << "\n";
  for (int i = 0; i < q; i++) {
    int u;
    cin >> u;
    u--;
    cur -= getVal(u);
    for (int v : frm[u]) {
      cur -= getVal(v);
      outdeg[v]--;
      frm[v].push_back(u);
      cur += getVal(v);
    }
    outdeg[u] += (int)frm[u].size();
    frm[u].clear();
    cout << cur << "\n";
  }
}
