#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 100010;
vector<int> g[N];
int in[N], out[N];
long long ans = 0;
int n, m, Q;
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    if (u > v) swap(u, v);
    in[u]++;
    out[v]++;
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) ans += 1ll * in[i] * out[i];
  cout << ans << endl;
  int Q = read();
  while (Q--) {
    int u = read();
    ans -= 1ll * in[u] * out[u];
    for (auto v : g[u]) {
      ans -= 1ll * in[v] * out[v];
      in[v]++, out[v]--;
      ans += 1ll * in[v] * out[v];
      in[u]--, out[u]++;
      g[v].push_back(u);
    }
    g[u].clear();
    cout << ans << endl;
  }
  return 0;
}
