#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
vector<vector<int> > ad(100005);
vector<pair<int, int> > vp(100005);
long long int ans;
void decrease(int x) {
  long long int temp;
  int a, b;
  tie(a, b) = vp[x];
  temp = a, temp *= b;
  ans -= temp;
  a++, b--;
  temp = a, temp *= b;
  ans += temp;
  vp[x] = {a, b};
}
void update(int x) {
  long long int temp;
  temp = vp[x].first, temp *= vp[x].second;
  ans -= temp;
  temp = vp[x].first + vp[x].second;
  vp[x] = {0, temp};
}
int main() {
  int n, m, i, a, b, q;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    a--, b--;
    if (a > b) swap(a, b);
    ad[a].emplace_back(b);
    vp[a].first++, vp[b].second++;
  }
  long long int temp;
  for (i = 0; i < n; i++) temp = vp[i].first, temp *= vp[i].second, ans += temp;
  scanf("%d", &q);
  cout << ans << "\n";
  while (q--) {
    scanf("%d", &a);
    a--;
    m = ad[a].size();
    for (i = 0; i < m; i++) {
      b = ad[a][i];
      ad[b].emplace_back(a);
      decrease(b);
    }
    ad[a].clear();
    update(a);
    cout << ans << "\n";
  }
}
