#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n, m, q, in[maxn + 5];
vector<int> g[maxn + 5];
long long res;
long long count(int id) { return 1ll * g[id].size() * in[id]; }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d %d", &u, &v);
    if (u > v) swap(u, v);
    g[u].push_back(v);
    in[v] += 1;
  }
  for (int i = 1; i <= n; ++i) res += count(i);
  printf("%lld\n", res);
  scanf("%d", &q);
  for (int i = 1, x; i <= q; ++i) {
    scanf("%d", &x);
    int sz = g[x].size();
    for (int j = sz - 1; j >= 0; --j) {
      int v = g[x][j];
      res -= count(x) + count(v);
      g[x].pop_back();
      g[v].push_back(x);
      in[v] -= 1, in[x] += 1;
      res += count(x) + count(v);
    }
    printf("%lld\n", res);
  }
  return 0;
}
