#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
const int maxm = 2000000 + 100;
const int maxt = 3000000 + 100;
const int maxk = 10 + 3;
const long long unit = 1LL;
const int INF = 0x3f3f3f3f;
const long long Inf = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-3;
const double inf = 1e15;
const double pi = acos(-1.0);
const long long mod = 1000000007LL;
inline long long read() {
  long long x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
vector<int> g[maxn];
int n, m;
long long deg[maxn];
int main() {
  n = read(), m = read();
  int u, v;
  for (int i = 1; i <= m; ++i) {
    u = read(), v = read();
    if (u > v) swap(u, v);
    g[u].push_back(v);
    ++deg[u], ++deg[v];
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += g[i].size() * (deg[i] - g[i].size());
  printf("%I64d\n", ans);
  int q = read();
  while (q--) {
    int x = read();
    ans -= g[x].size() * (deg[x] - g[x].size());
    for (auto y : g[x]) {
      ans += deg[y] - 2LL * g[y].size() - 1;
      g[y].push_back(x);
    }
    g[x].clear();
    printf("%I64d\n", ans);
  }
  return 0;
}
