#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<int>> g;
vector<int> deg;
ll ans;
int n, m;
void add_edge(int x, int y) {
  if (x > y) {
    int t = x;
    x = y;
    y = t;
  }
  g[x].push_back(y);
  deg[x]++;
  deg[y]++;
}
void init() {
  scanf("%d %d", &n, &m);
  deg.resize(n, 0);
  g.resize(n, vector<int>());
  ans = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    add_edge(x, y);
  }
  ans = 0;
  for (int i = 0; i < n; i++)
    ans += (ll)g[i].size() * (ll)(deg[i] - g[i].size());
}
void work() {
  int Q;
  cout << ans << endl;
  scanf("%d", &Q);
  for (int qi = 0; qi < Q; qi++) {
    int x;
    scanf("%d", &x);
    x--;
    ans -= (ll)g[x].size() * (ll)(deg[x] - g[x].size());
    ans += 0;
    for (int y : g[x]) {
      ll y_size = g[y].size();
      ans -= (ll)y_size * (ll)(deg[y] - y_size);
      g[y].push_back(x);
      y_size++;
      ans += (ll)y_size * (ll)(deg[y] - y_size);
    }
    g[x].clear();
    printf("%lld\n", ans);
  }
}
int main() {
  init();
  work();
  return 0;
}
