#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma comment(linker, "/STACK:256000000")
using namespace std;
static const int _ = []() {
  ios::sync_with_stdio(false);
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return 0;
}();
__attribute__((aligned(64))) vector<int> in[100007];
__attribute__((aligned(64))) int out[100007];
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    in[u].push_back(v);
    out[v]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += in[i].size() * out[i];
  }
  cout << ans << '\n';
  int q;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    ans -= in[x].size() * out[x];
    out[x] += in[x].size();
    for (int& inx : in[x]) {
      ans -= in[inx].size();
      out[inx]--;
      ans += out[inx];
      in[inx].push_back(x);
    }
    in[x].clear();
    cout << ans << '\n';
  }
  return 0;
}
