#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const int maxn = 1e6 + 5;
int n, m;
vector<int> g[maxn];
ll ind[maxn], outd[maxn];
ll ans = 0;
void edit(int at) {
  for (int to : g[at]) {
    ans -= ind[to] * outd[to];
    outd[to]--;
    ind[to]++;
    ans += ind[to] * outd[to];
    g[to].push_back(at);
  }
  ans -= ind[at] * outd[at];
  outd[at] += ind[at];
  ind[at] = 0;
  g[at].clear();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    assert(u < v);
    ind[u]++;
    outd[v]++;
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    ans += ind[i] * outd[i];
  }
  cout << ans << "\n";
  int q;
  cin >> q;
  while (q--) {
    int at;
    cin >> at;
    edit(at);
    cout << ans << "\n";
  }
  return 0;
}
