#include <bits/stdc++.h>
using namespace std;
const long long maxm = 1e5 + 5;
vector<long long> g[maxm];
long long in[maxm], out[maxm];
long long n, m;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    g[a].push_back(b);
    out[a]++, in[b]++;
  }
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    sum += in[i] * out[i];
  }
  cout << sum << endl;
  long long q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    sum -= in[x] * out[x];
    for (long long v : g[x]) {
      g[v].push_back(x);
      sum -= in[v] * out[v];
      in[v]--;
      out[v]++;
      out[x]--;
      in[x]++;
      sum += in[v] * out[v];
    }
    sum += in[x] * out[x];
    g[x].clear();
    cout << sum << endl;
  }
  return 0;
}
