#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> g[maxn];
int in[maxn], out[maxn], n, m, q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    g[x].push_back(y);
    in[x]++;
    out[y]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += 1ll * in[i] * out[i];
  printf("%lld\n", ans);
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    ans -= 1ll * in[x] * out[x];
    for (int y : g[x]) {
      g[y].push_back(x);
      ans -= 1ll * in[y] * out[y];
      in[x]--, out[y]--, out[x]++, in[y]++;
      ans += 1ll * in[y] * out[y];
    }
    g[x].clear();
    printf("%lld\n", ans);
  }
}
