#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
const int DIM = 20000;
unsigned long long in[NMAX];
unsigned long long out[NMAX];
unsigned long long val[NMAX];
vector<int> vec[NMAX];
char buff[DIM];
int poz = 0;
vector<int> g[NMAX];
vector<int> gv[NMAX];
void citeste(int &numar) {
  numar = 0;
  while (buff[poz] < '0' || buff[poz] > '9')
    if (++poz == DIM) fread(buff, 1, DIM, stdin), poz = 0;
  while ('0' <= buff[poz] && buff[poz] <= '9') {
    numar = numar * 10 + buff[poz] - '0';
    if (++poz == DIM) fread(buff, 1, DIM, stdin), poz = 0;
  }
}
int main() {
  int n, m, i, a, b, p, qq;
  citeste(n);
  citeste(m);
  for (i = 1; i <= m; i++) {
    citeste(a);
    citeste(b);
    vec[min(a, b)].push_back(max(a, b));
    out[min(a, b)]++;
    in[max(a, b)]++;
  }
  unsigned long long sol = 0;
  for (i = 1; i <= n; i++) {
    val[i] = i;
    sol = sol + in[i] * out[i];
  }
  printf("%I64d\n", sol);
  int q;
  citeste(q);
  for (qq = 1; qq <= q; qq++) {
    citeste(p);
    for (auto u : vec[p]) {
      if (val[u] > val[p]) {
        sol = sol - in[u] * out[u];
        in[u]--;
        out[u]++;
        sol = sol + in[u] * out[u];
        vec[u].push_back(p);
      }
    }
    sol = sol - in[p] * out[p];
    in[p] += out[p];
    out[p] = 0;
    val[p] = n + qq;
    vec[p].clear();
    printf("%I64d\n", sol);
  }
  return 0;
}
