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