#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
long long a, b, ans;
long long in[100000 + 5], out[100000 + 5];
vector<long long> path[100000 + 5];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    path[min(a, b)].push_back(max(a, b));
    in[min(a, b)]++;
    out[max(a, b)]++;
  }
  for (long long i = 1; i <= n; i++) {
    ans += in[i] * out[i];
  }
  cout << ans << endl;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> a;
    ans -= in[a] * out[a];
    out[a] += in[a];
    in[a] = 0;
    for (long long j = 0; j < path[a].size(); j++) {
      path[path[a][j]].push_back(a);
      ans -= in[path[a][j]] * out[path[a][j]];
      in[path[a][j]]++, out[path[a][j]]--;
      ans += in[path[a][j]] * out[path[a][j]];
    }
    path[a].clear();
    cout << ans << endl;
  }
  return 0;
}
