#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, INF = 0x3f3f3f3f, M = N << 1;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
vector<int> G[N];
int in[N], out[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, q, u, v;
  long long ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    G[u].emplace_back(v), in[v]++, out[u]++;
  }
  cin >> q;
  for (int i = 1; i <= n; ++i) ans += 1ll * in[i] * out[i];
  cout << ans << '\n';
  while (q--) {
    cin >> u;
    ans -= 1ll * in[u] * out[u];
    in[u] += out[u];
    out[u] = 0;
    for (int v : G[u]) {
      in[v]--, out[v]++;
      ans += in[v] - out[v] + 1;
      G[v].emplace_back(u);
    }
    G[u].clear();
    cout << ans << '\n';
  }
}
