#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[100005];
vector<long long> bigs[100005];
long long tot[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, m, i, j, k;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
      long long x, y;
      cin >> x >> y;
      if (x < y) swap(x, y);
      tot[x]++, tot[y]++;
      bigs[y].push_back(x);
    }
    long long ans = 0, q;
    for (i = 1; i <= n; i++)
      ans += ((tot[i] - (long long int)bigs[i].size()) *
              (long long int)bigs[i].size());
    cin >> q;
    cout << ans << "\n";
    while (q--) {
      long long num;
      cin >> num;
      ans -= ((tot[num] - (long long int)bigs[num].size()) *
              (long long int)bigs[num].size());
      while (!bigs[num].empty()) {
        long long x = bigs[num].back();
        ans -= ((long long int)bigs[x].size());
        bigs[x].push_back(num);
        ans += (tot[x] - (long long int)bigs[x].size());
        bigs[num].pop_back();
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
