#include <bits/stdc++.h>
using namespace std;
const int MX = 100000 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n, m, q;
int du[MX];
vector<int> E[MX];
long long cal(int i) { return 1ll * du[i] * E[i].size(); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    du[v]++;
    E[u].push_back(v);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += cal(i);
  printf("%lld\n", ans);
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    ans -= cal(x);
    for (auto v : E[x]) {
      ans -= cal(v);
      du[v]--;
      E[v].push_back(x);
      ans += cal(v);
    }
    du[x] += E[x].size();
    E[x].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
