#include <bits/stdc++.h>
using namespace std;
vector<int> e[100005], S[100005];
int f[100005], g[100005], a[100005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) a[i] = i;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    e[u].push_back(v), e[v].push_back(u);
    f[v]++, g[u]++, S[u].emplace_back(v);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans = ans + 1ll * f[i] * g[i];
  cout << ans << endl;
  int Q;
  cin >> Q;
  for (int k = 1; k <= Q; ++k) {
    int x;
    cin >> x;
    for (int i = 0; i < S[x].size(); ++i) {
      int y = S[x][i];
      ans = ans - 1ll * f[x] * g[x];
      ans = ans - 1ll * f[y] * g[y];
      f[y]--, g[y]++, g[x]--, f[x]++;
      S[y].push_back(x);
      ans = ans + 1ll * f[x] * g[x];
      ans = ans + 1ll * f[y] * g[y];
    }
    S[x].clear();
    a[x] = n + k;
    cout << ans << endl;
  }
  return 0;
}
