#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> g[100010];
int deg[100010];
int in[100010];
int out[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a < b) {
      swap(a, b);
    }
    out[a]++;
    in[b]++;
    deg[a]++;
    deg[b]++;
    g[b].push_back(a);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1ll * out[i] * in[i];
  }
  printf("%lld\n", ans);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int a;
    scanf("%d", &a);
    ans -= 1ll * in[a] * out[a];
    in[a] = 0;
    out[a] = deg[a];
    for (int j = 0; j < g[a].size(); j++) {
      int ver = g[a][j];
      ans -= 1ll * in[ver] * out[ver];
      in[ver]++;
      out[ver]--;
      ans += 1ll * in[ver] * out[ver];
      g[ver].push_back(a);
    }
    g[a].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
