#include <bits/stdc++.h>
const int N = 100005;
int n, m, head[N], tot, deg[N], x, y, q;
std::vector<int> bigger[N];
long long ans = 0;
struct edge {
  int to, nxt;
} e[N << 1];
long long value(int x) {
  return (long long)bigger[x].size() * (deg[x] - bigger[x].size());
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    std::cin >> x >> y, ++deg[x], ++deg[y];
    if (x > y) std::swap(x, y);
    bigger[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i) ans += value(i);
  std::cin >> q;
  for (int i = 1; i <= q; ++i) {
    std::cout << ans << '\n';
    std::cin >> x, ans -= value(x);
    for (int j : bigger[x])
      ans -= value(j), bigger[j].push_back(x), ans += value(j);
    bigger[x].clear();
  }
  std::cout << ans << '\n';
  return 0;
}
