#include <bits/stdc++.h>
const long long maxn = 1e5 + 10;
inline long long read() {
  long long f = 1, r = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    r = 10 * r + c - '0';
    c = getchar();
  }
  return f * r;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(long long x) { write(x), putchar(' '); }
inline void writeln(long long x) { write(x), puts(""); }
long long N, M, tot, Q, in[maxn], out[maxn];
std::vector<long long> vec[maxn];
signed main() {
  N = read(), M = read();
  for (register long long i = 1; i <= M; ++i) {
    long long u = read(), v = read();
    if (u > v) {
      std::swap(u, v);
    }
    in[u]++, out[v]++;
    vec[u].push_back(v);
  }
  long long ans = 0;
  for (register long long i = 1; i <= N; ++i) {
    ans += in[i] * out[i];
  }
  writeln(ans);
  Q = read();
  for (register long long i = 1; i <= Q; ++i) {
    long long q = read(), tmp = out[q] * in[q];
    ans -= tmp;
    for (register long long j = 0; j < vec[q].size(); ++j) {
      long long v = vec[q][j];
      ans -= in[v] * out[v];
      in[v]++, out[v]--;
      ans += in[v] * out[v];
      vec[v].push_back(q);
    }
    out[q] += in[q], in[q] = 0, vec[q].clear();
    writeln(ans);
  }
  return 0;
}
