#include <bits/stdc++.h>
using namespace std;
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long N = 2e5 + 5;
const long long M = 2e6 + 5;
const long long L = 2e1 + 1;
const long long inf = 9e17;
const long long mod = 1e9 + 7;
long long xyz = 1;
long long n, m, q;
long long ans;
long long out[N];
long long val[N];
vector<long long> con[N];
long long upd(long long x) {
  long long old = val[x];
  val[x] = con[x].size() * out[x];
  return val[x] - old;
}
void cal(long long x) {
  ans -= out[x] * con[x].size();
  val[x] = 0;
  out[x] += con[x].size();
  for (long long adj : con[x]) {
    out[adj]--;
    con[adj].push_back(x);
    ans += upd(adj);
  }
  con[x].clear();
}
void run() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long u;
    long long v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    con[u].push_back(v);
    out[v]++;
  }
  for (long long i = 1; i <= n; i++) ans += (val[i] = out[i] * con[i].size());
  cout << ans << "\n";
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    cal(x);
    cout << ans << "\n";
  }
}
signed main() {
  setIO();
  while (xyz--) run();
  return 0;
}
