#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, q;
long long ans;
int od[N], id[N];
vector<int> g[N];
void alter(int x) {
  int sub = od[x];
  for (auto y : g[x]) {
    g[y].push_back(x);
    ans += (od[y] - 1) - id[y] - sub;
    --id[x], ++od[x], ++id[y], --od[y];
  }
  g[x].clear();
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if (x > y) {
      swap(x, y);
    }
    g[x].push_back(y);
    ++id[x], ++od[y];
  }
  for (int i = 1; i <= n; ++i) {
    for (auto j : g[i]) {
      ans += id[j];
    }
  }
  scanf("%d", &q);
  printf("%lld\n", ans);
  for (int qaq = 1, x; qaq <= q; ++qaq) {
    scanf("%d", &x);
    alter(x);
    printf("%lld\n", ans);
  }
  return 0;
}
