#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
const int MX = 100 * 1000 + 7;
const int SQRT = 307;
vector<int> out[MX];
int indeg[MX], outdeg[MX];
int sal[MX];
ll f(int v) { return 1ll * indeg[v] * outdeg[v]; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    sal[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) {
      swap(u, v);
    }
    outdeg[u]++;
    indeg[v]++;
    out[u].push_back(v);
  }
  vector<int> all;
  for (int i = 1; i <= n; i++) {
    all.push_back(i);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += f(i);
  }
  cout << ans << "\n";
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    if (i % SQRT == 0) {
      for (int v = 1; v <= n; v++) {
        vector<int> real;
        for (int u : out[v]) {
          if (sal[u] > sal[v]) {
            real.push_back(u);
          }
        }
        out[v] = real;
      }
    }
    int v;
    cin >> v;
    ans -= f(v);
    for (int u : out[v]) {
      if (sal[u] > sal[v]) {
        ans -= f(u);
        outdeg[v]--;
        indeg[v]++;
        outdeg[u]++;
        indeg[u]--;
        out[u].push_back(v);
        ans += f(u);
      }
    }
    sal[v] = n + i;
    out[v].clear();
    cout << ans << "\n";
  }
  return 0;
}
