#include <bits/stdc++.h>
using namespace std;
vector<int> H[100003];
int deg[100003] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) {
      swap(a, b);
    }
    H[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  long long dd = 0;
  for (int i = 0; i < n; i++) {
    long long h = H[i].size();
    dd += (deg[i] - h) * h;
  }
  cout << dd << endl;
  int q;
  cin >> q;
  while (q-- > 0) {
    int v;
    cin >> v;
    v--;
    for (auto x : H[v]) {
      H[x].push_back(v);
      long long ph = H[x].size() - 1;
      long long nh = ph + 1;
      dd += (deg[x] - nh) * nh - (deg[x] - ph) * ph;
    }
    long long vh = H[v].size();
    dd -= vh * (deg[v] - vh);
    H[v].clear();
    cout << dd << endl;
  }
  return 0;
}
