#include <bits/stdc++.h>
using namespace std;
const int maxn = 100179;
vector<int> up[maxn];
int cnt[maxn];
int value[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  iota(value, value + n, 0);
  for (int i = 0; i < (int)(m); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (u < v) swap(u, v);
    up[v].push_back(u);
    cnt[v]++;
    cnt[u]++;
  }
  long long ans = 0;
  for (int i = 0; i < (int)(n); i++)
    ans += 1ll * up[i].size() * (cnt[i] - up[i].size());
  cout << ans << endl;
  int q;
  cin >> q;
  for (int j = 0; j < (int)(q); j++) {
    int v;
    cin >> v;
    v--;
    value[v] = n + j;
    ans -= 1ll * up[v].size() * (cnt[v] - up[v].size());
    for (auto u : up[v]) {
      ans -= 1ll * up[u].size() * (cnt[u] - up[u].size());
      up[u].push_back(v);
      ans += 1ll * up[u].size() * (cnt[u] - up[u].size());
    }
    up[v].clear();
    cout << ans << endl;
  }
  return 0;
}
