#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, u, v, i, ans = 0, q;
  cin >> n >> m;
  pair<long long, long long> deg[n + 1];
  vector<long long> adj[n + 1];
  for (i = 0; i <= n; i++) deg[i].first = deg[i].second = 0;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    adj[min(u, v)].push_back(max(u, v));
    deg[min(u, v)].second++;
    deg[max(u, v)].first++;
  }
  for (i = 1; i <= n; i++) {
    ans += deg[i].first * deg[i].second;
  }
  cin >> q;
  cout << ans << endl;
  for (i = 0; i < q; i++) {
    cin >> u;
    ans -= deg[u].first * deg[u].second;
    while (!adj[u].empty()) {
      v = adj[u].back();
      ans -= deg[v].first * deg[v].second;
      deg[v].first--;
      deg[v].second++;
      ans += deg[v].first * deg[v].second;
      adj[v].push_back(u);
      adj[u].pop_back();
    }
    deg[u].first += deg[u].second;
    deg[u].second = 0;
    cout << ans << endl;
  }
}
