#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 555;
int incnt[maxn];
int outcnt[maxn];
int val[maxn];
vector<int> out[maxn];
long long ans = 0;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
void solve() {
  int n, m;
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int a, b;
    a = read();
    b = read();
    if (a > b) swap(a, b);
    outcnt[a]++;
    incnt[b]++;
    out[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    val[i] = i;
    ans += 1ll * incnt[i] * outcnt[i];
  }
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  while (q--) {
    int v = read();
    for (int d : out[v]) {
      out[d].push_back(v);
      ans -= 1ll * incnt[d] * outcnt[d];
      incnt[d]--;
      outcnt[d]++;
      ans += 1ll * incnt[d] * outcnt[d];
    }
    ans -= 1ll * incnt[v] * outcnt[v];
    incnt[v] += outcnt[v];
    outcnt[v] = 0;
    out[v].clear();
    printf("%lld\n", ans);
  }
}
signed main() { solve(); }
