#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
int n, m, in[M], out[M];
long long ans;
vector<int> v[M];
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    v[a].push_back(b);
    out[a]++, in[b]++;
    ans += in[a] + out[b];
  }
  printf("%lld\n", ans);
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    for (int i = 0; i < v[x].size(); i++) {
      int y = v[x][i];
      if (!y) continue;
      v[x][i] = 0;
      ans -= in[x] + out[y];
      out[x]--, in[y]--;
      v[y].push_back(x);
      in[x]++, out[y]++;
      ans += out[x] + in[y];
    }
    v[x].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
