#include <bits/stdc++.h>
using namespace std;
const int MAXN_1e5 = 1e5 + 5;
const int MAXN_2e5 = 2e5 + 5;
const int MAXN_3e5 = 3e5 + 5;
const int MAXN_4e5 = 4e5 + 5;
const int MAXN_5e5 = 5e5 + 5;
const int INF_INT = 0x3f3f3f3f;
const long long INT_LL = 2e18;
vector<int> edges[MAXN_1e5];
long long in[MAXN_1e5], out[MAXN_1e5];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) {
      swap(a, b);
    }
    edges[a].push_back(b);
    out[a]++;
    in[b]++;
  }
  long long ans = 0;
  for (int u = 1; u <= n; u++) {
    for (auto v : edges[u]) {
      ans += out[v];
    }
  }
  int q;
  scanf("%d", &q);
  printf("%lld\n", ans);
  while (q--) {
    long long u;
    scanf("%lld", &u);
    ans -= out[u] * in[u];
    in[u] += out[u];
    out[u] = 0;
    for (auto v : edges[u]) {
      ans -= out[v];
      in[v]--;
      out[v]++;
      ans += in[v];
      edges[v].push_back(u);
    }
    edges[u].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
