#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
const int maxn = 101000;
vector<unsigned> mor[maxn];
int les[maxn];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m;
  read(n), read(m);
  for (int i = 1; i <= m; i += 1) {
    int x, y;
    read(x), read(y);
    if (x > y) swap(x, y);
    mor[x].push_back(y), ++les[y];
  }
  unsigned ans = 0;
  for (int i = 1; i <= n; i += 1) {
    ans += (les[i]) * (mor[i].size());
  }
  int q;
  read(q);
  cout << ans << '\n';
  while (q--) {
    int x;
    read(x);
    ans -= (les[x]) * (mor[x].size());
    for (auto j : mor[x]) {
      ans += (les[j]) - (mor[j].size()) - 1;
      mor[j].push_back(x);
      --les[j];
      ++les[x];
    }
    mor[x].clear();
    cout << ans << '\n';
  }
  return 0;
}
