#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
forward_list<int> in[maxn];
int ind[maxn], outd[maxn];
int n, m, q;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (x < y) swap(x, y);
    outd[x]++;
    ind[y]++;
    in[y].push_front(x);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) ans += 1LL * ind[i] * outd[i];
  cout << ans << "\n";
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    ans -= 1LL * ind[x] * outd[x];
    outd[x] += ind[x];
    ind[x] = 0;
    for (auto y : in[x]) {
      ans = ans - ind[y] + outd[y] - 1;
      ind[y]++;
      outd[y]--;
      in[y].push_front(x);
    }
    in[x].clear();
    cout << ans << "\n";
  }
  return 0;
}
