#include <bits/stdc++.h>
using namespace std;
void err() { cout << endl; }
template <class T, class... Ts>
void err(const T &arg, const Ts &...args) {
  cout << arg << ' ';
  err(args...);
}
using ll = long long;
using db = double;
const int N = 1e5 + 10;
int n, m, q;
int deg[N];
vector<vector<int>> G;
ll f(ll x) { return 1ll * (deg[x] - G[x].size()) * G[x].size(); }
void RUN() {
  while (cin >> n >> m) {
    G.clear();
    G.resize(n + 1);
    memset(deg, 0, sizeof deg);
    for (int i = 1, u, v; i <= m; ++i) {
      cin >> u >> v;
      if (u > v) {
        swap(u, v);
      }
      deg[u]++, deg[v]++;
      G[u].push_back(v);
    }
    ll res = 0;
    for (int i = 1; i <= n; ++i) {
      res += f(i);
    }
    cout << res << "\n";
    cin >> q;
    while (q--) {
      int u;
      cin >> u;
      res -= f(u);
      for (auto &v : G[u]) {
        res -= f(v);
        G[v].push_back(u);
        res += f(v);
      }
      G[u].clear();
      res += f(u);
      cout << res << "\n";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  RUN();
  return 0;
}
