#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100010];
int deg[100010];
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);
    }
    v[x].push_back(y);
    deg[x]++;
    deg[y]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (long long)(deg[i] - v[i].size()) * v[i].size();
  }
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x;
    scanf("%d", &x);
    ans -= (long long)(deg[x] - v[x].size()) * v[x].size();
    while (!v[x].empty()) {
      int y = v[x].back();
      v[x].pop_back();
      ans -= (long long)(deg[y] - v[y].size()) * v[y].size();
      v[y].push_back(x);
      ans += (long long)(deg[y] - v[y].size()) * v[y].size();
    }
    printf("%lld\n", ans);
  }
  return 0;
}
