#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, m;
vector<int> vec[N];
int du[N], out[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    du[p]++;
    du[q]++;
    if (p < q) {
      out[p]++;
      vec[p].push_back(q);
    } else {
      out[q]++;
      vec[q].push_back(p);
    }
  }
  int Q;
  scanf("%d", &Q);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += 1ll * (du[i] - out[i]) * out[i];
  }
  cout << res << "\n";
  for (int k = 1; k <= Q; k++) {
    int x;
    scanf("%d", &x);
    for (int i = 0; i < vec[x].size(); i++) {
      int v = vec[x][i];
      vec[v].push_back(x);
      res -= 1ll * (du[x] - out[x]) * out[x];
      res -= 1ll * (du[v] - out[v]) * out[v];
      out[x]--;
      out[v]++;
      res += 1ll * (du[x] - out[x]) * out[x];
      res += 1ll * (du[v] - out[v]) * out[v];
    }
    vec[x].clear();
    cout << res << "\n";
  }
}
