#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int mod0 = 1e9 + 7;
const long long mod1 = 998244353;
const long long mod2 = 1e9 + 9;
const long long mod3 = 2147483647;
const long long inf = 2 * 1024 * 1024 * 1023 - 1;
const long long INF = inf * inf;
const int sz = 256 * 1024;
const long double eps = 1e-7;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int K = 500;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<long long> cnt1(n), cnt2(n);
  long long ans = 0;
  vector<bool> heavy(n);
  set<pair<int, int>> e;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    e.insert({a, b});
    e.insert({b, a});
    g[a].push_back(b), g[b].push_back(a);
    if (a > b) {
      cnt1[a]++, cnt2[b]++;
    } else {
      cnt1[b]++, cnt2[a]++;
    }
  }
  vector<int> x(n);
  for (int i = 0; i < n; ++i) x[i] = i;
  for (int i = 0; i < n; ++i) {
    if (g[i].size() > K) {
      heavy[i] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    ans += cnt1[i] * cnt2[i];
  }
  cout << ans << '\n';
  int q;
  cin >> q;
  int idx = -1;
  vector<int> t(n, -1);
  vector<int> Q(q);
  for (int i0 = 0; i0 < q; ++i0) {
    int i;
    cin >> i;
    i--;
    Q[i0] = i;
    if (idx == i) {
      cout << ans << '\n';
      continue;
    }
    idx = i;
    ans -= cnt1[i] * cnt2[i];
    cnt1[i] = g[i].size(), cnt2[i] = 0;
    if (g[i].size() <= K || t[i] == -1) {
      for (int j : g[i]) {
        if (x[i] < x[j]) {
          ans -= cnt2[j];
          cnt1[j]--, cnt2[j]++;
          ans += cnt1[j];
        }
      }
    } else {
      set<int> used;
      for (int j0 = t[i] + 1; j0 < i0; ++j0) {
        int j = Q[j0];
        if (used.count(j) || !e.count({i, j})) continue;
        used.insert(j);
        ans -= cnt2[j];
        cnt1[j]--, cnt2[j]++;
        ans += cnt1[j];
      }
    }
    t[i] = i0;
    x[i] = i0 + n;
    cout << ans << '\n';
  }
}
bool multitest = false;
int main() {
  init();
  int t = 1;
  if (multitest) cin >> t;
  for (int i = 0; i < t; ++i) solve();
  return 0;
}
