#include <bits/stdc++.h>
using namespace std;
const int MXN = 1000010;
const int C = 262144;
const int INF = 1000000001;
int n, m, in[MXN], out[MXN];
vector<int> U[MXN];
void test() {
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (m); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) swap(a, b);
    out[a]++;
    in[b]++;
    U[b].push_back(a);
  }
  long long int res = 0;
  for (int i = (1); i <= (n); i++) res += (long long int)out[i] * in[i];
  int q;
  scanf("%d", &q);
  printf("%I64d\n", res);
  while (q--) {
    int x;
    scanf("%d", &x);
    res -= (long long int)out[x] * in[x];
    for (__typeof((U[x]).begin()) it = ((U[x]).begin()); it != (U[x]).end();
         ++it) {
      res += out[*it] - 1;
      res -= in[*it];
      out[*it]--;
      in[*it]++;
      U[*it].push_back(x);
    }
    out[x] += in[x];
    in[x] = 0;
    U[x].clear();
    printf("%I64d\n", res);
  }
}
int main() {
  int te = 1;
  while (te--) test();
  return 0;
}
