#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, d[N], z[N], q;
vector<int> e[N];
long long a;
long long C(int x) { return (long long)z[x] * (d[x] - z[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    d[x]++;
    d[y]++;
    if (x > y) swap(x, y);
    e[x].push_back(y);
    z[x]++;
  }
  for (int i = 1; i <= n; i++) a += C(i);
  printf("%lld\n", a);
  scanf("%d", &q);
  for (int v; q--;) {
    scanf("%d", &v);
    a -= C(v);
    for (int u, i = 0; i < z[v]; i++) {
      u = e[v][i];
      a -= C(u);
      e[u].push_back(v);
      z[u]++;
      a += C(u);
    }
    z[v] = 0;
    e[v].clear();
    printf("%lld\n", a);
  }
  return 0;
}
