#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int next[1 + 100000 * 2], aa[1 + 100000 * 2], _;
int link(int l, int a) {
  next[_] = l;
  aa[_] = a;
  return _++;
}
int main() {
  static int ii[100000], jj[100000], ko[100000], ki[100000], vv[100000],
      rank[100000], ao[100000], ao_[100000];
  static char used[100000];
  int n, m, q, g, h, i, j;
  long long ans;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) rank[i] = i;
  for (h = 0; h < m; h++) {
    int tmp;
    scanf("%d%d", &i, &j), i--, j--;
    if (rank[i] < rank[j]) tmp = i, i = j, j = tmp;
    ii[h] = i, jj[h] = j;
    ko[i]++, ki[j]++;
  }
  scanf("%d", &q);
  for (h = 0; h < q; h++) scanf("%d", &vv[h]), vv[h]--;
  ans = 0;
  for (i = 0; i < n; i++) ans += (long long)ko[i] * ki[i];
  printf("%lld\n", ans);
  for (g = 0; g * 320 < q; g++) {
    int lower = g * 320, upper = min((g + 1) * 320, q);
    memset(used, 0, n * sizeof *used);
    memset(ko, 0, n * sizeof *ko);
    memset(ki, 0, n * sizeof *ki);
    _ = 1;
    memset(ao, 0, n * sizeof *ao);
    memset(ao_, 0, n * sizeof *ao_);
    for (h = lower; h < upper; h++) used[vv[h]] = 1;
    for (h = 0; h < m; h++) {
      int tmp;
      i = ii[h], j = jj[h];
      if (rank[i] < rank[j]) tmp = i, i = j, j = tmp;
      ko[i]++, ki[j]++;
      if (used[i] && used[j]) {
        ao[i] = link(ao[i], j);
        ao[j] = link(ao[j], i);
      } else if (!used[i] && used[j])
        ao_[j] = link(ao_[j], i);
    }
    ans = 0;
    for (i = 0; i < n; i++) ans += (long long)ko[i] * ki[i];
    for (h = lower; h < upper; h++) {
      int l;
      i = vv[h];
      for (l = ao[i]; l; l = next[l]) {
        j = aa[l];
        if (rank[i] < rank[j]) {
          ans -= (long long)ko[i] * ki[i] + (long long)ko[j] * ki[j];
          ko[j]--, ki[i]--;
          ko[i]++, ki[j]++;
          ans += (long long)ko[i] * ki[i] + (long long)ko[j] * ki[j];
        }
      }
      for (l = ao_[i]; l; l = next[l]) {
        j = aa[l];
        ans -= (long long)ko[i] * ki[i] + (long long)ko[j] * ki[j];
        ko[j]--, ki[i]--;
        ko[i]++, ki[j]++;
        ans += (long long)ko[i] * ki[i] + (long long)ko[j] * ki[j];
      }
      ao_[i] = 0;
      rank[i] = n + h;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
