#include <bits/stdc++.h>
const int MAX_N = 100000;
std::vector<int> G[1 + MAX_N];
long long val[1 + MAX_N];
int in[1 + MAX_N];
int out[1 + MAX_N];
long long ans;
int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    std::cin >> u >> v;
    G[std::min(u, v)].push_back(std::max(u, v));
    out[std::min(u, v)]++;
    in[std::max(u, v)]++;
  }
  for (int i = 1; i <= n; i++) {
    ans += 1LL * in[i] * out[i];
    val[i] = i;
  }
  std::cout << ans << '\n';
  int Q;
  std::cin >> Q;
  for (int q = 1; q <= Q; q++) {
    int u;
    std::cin >> u;
    ans -= 1LL * in[u] * out[u];
    for (int v : G[u])
      if (val[v] > val[u]) {
        ans -= 1LL * in[v] * out[v];
        in[v]--;
        out[v]++;
        ans += 1LL * in[v] * out[v];
        G[v].push_back(u);
      }
    in[u] += out[u];
    out[u] = 0;
    val[u] = n + q;
    G[u].clear();
    std::cout << ans << '\n';
  }
  return 0;
}
