#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
long long ru[N], cu[N];
vector<long long> v[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long n, m, q, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    v[x].push_back(y);
    cu[x]++;
    ru[y]++;
  }
  for (int i = 1; i <= n; i++) ans += ru[i] * cu[i];
  printf("%lld\n", ans);
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    ans -= cu[x] * ru[x];
    for (int y : v[x]) {
      v[y].push_back(x);
      ans -= cu[y] * ru[y];
      cu[x]--;
      ru[x]++;
      cu[y]++;
      ru[y]--;
      ans += cu[y] * ru[y];
    }
    v[x].clear();
    ans += cu[x] * ru[x];
    printf("%lld\n", ans);
  }
  return 0;
}
