#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 23;
int n, m, u, v, q;
long long ans;
int out[maxn];
vector<int> in[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    if (u < v) swap(u, v);
    out[u]++;
    in[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) ans += 1ll * in[i].size() * out[i];
  printf("%lld\n", ans);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &u);
    ans -= 1ll * (int)in[u].size() * out[u];
    for (auto i : in[u]) {
      ans += (out[i] - (int)in[i].size() - 1);
      out[i]--;
      in[i].push_back(u);
      out[u]++;
    }
    in[u].resize(0);
    printf("%lld\n", ans);
  }
}
