#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
const int INF = 0x3f3f3f3f;
vector<int> vec[maxn];
long long rd[maxn], cd[maxn], ans;
void dfs(int k) {
  long long r = rd[k];
  long long c = cd[k];
  cd[k] += rd[k];
  rd[k] = 0;
  ans -= r * c;
  for (int i = 0; i < vec[k].size(); i++) {
    int j = vec[k][i];
    ans -= cd[j] * rd[j];
    cd[j]--;
    rd[j]++;
    ans += cd[j] * rd[j];
    vec[j].push_back(k);
  }
  vec[k].clear();
}
int main() {
  int i, j, k, n, m, u, v;
  memset(rd, 0, sizeof(rd));
  memset(cd, 0, sizeof(cd));
  for (i = 0; i < maxn; i++) vec[i].clear();
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    u = max(x, y);
    v = min(x, y);
    vec[v].push_back(u);
    rd[v]++;
    cd[u]++;
  }
  ans = 0;
  for (i = 1; i <= n; i++) ans += rd[i] * cd[i];
  int q;
  printf("%lld\n", ans);
  scanf("%d", &q);
  for (i = 1; i <= q; i++) {
    scanf("%d", &v);
    dfs(v);
    printf("%lld\n", ans);
  }
}
