#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m;
vector<int> g[200005];
long long sum = 0;
long long in[200005], out[200005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, a, b; i <= m; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    g[a].push_back(b);
    out[a]++, in[b]++;
  }
  for (int i = 1; i <= n; i++) {
    sum += in[i] * out[i];
  }
  printf("%lld\n", sum);
  int q;
  scanf("%d", &q);
  while (q--) {
    int t;
    scanf("%d", &t);
    sum -= in[t] * out[t];
    for (int y : g[t]) {
      sum -= in[y] * out[y];
      in[y]--;
      out[y]++;
      in[t]++;
      out[t]--;
      sum += in[y] * out[y];
      g[y].push_back(t);
    }
    g[t].clear();
    sum += in[t] * out[t];
    printf("%lld\n", sum);
  }
}
