#include <bits/stdc++.h>
using namespace std;
set<int> s[100005];
int deg[100005], cur[100005], indeg[100005];
int a[100005], b[100005];
bool vis[100005], ch[100005];
const int SQ = 400;
vector<int> tdj[100005];
vector<int> adj[100005];
long long clear(int n, int m) {
  for (int i = n; i; --i) {
    vis[i] = false;
    ch[i] = false;
    indeg[i] = 0;
    adj[i].clear();
  }
  for (int i = 0; i < m; ++i) {
    if (cur[a[i]] < cur[b[i]]) {
      ++indeg[a[i]];
    } else {
      ++indeg[b[i]];
    }
  }
  long long ret = 0;
  for (int i = n; i; --i) {
    ret += (long long)(deg[i] - indeg[i]) * indeg[i];
  }
  return ret;
}
int v[100005];
void solve() {
  int n, m;
  scanf("%d %d ", &n, &m);
  for (int i = n; i; --i) {
    cur[i] = i;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d %d ", &a[i], &b[i]);
    ++deg[a[i]];
    ++deg[b[i]];
    tdj[a[i]].push_back(b[i]);
    tdj[b[i]].push_back(a[i]);
  }
  int q;
  scanf("%d ", &q);
  long long ret = clear(n, m);
  printf("%lld\n", ret);
  for (int i = 1; i <= q; ++i) {
    scanf("%d ", &v[i]);
  }
  for (int i = 1; i <= q;) {
    int ed = min(i + SQ - 1, q);
    if (i != 1) ret = clear(n, m);
    int pos = 0;
    for (int j = i; j <= ed; ++j) {
      ch[v[j]] = true;
    }
    for (int j = 1; j <= n; ++j) {
      if (ch[j]) {
        for (int node : tdj[j]) {
          if (ch[node]) {
            adj[j].push_back(node);
          }
        }
      }
    }
    for (int j = i; j <= ed; ++j) {
      int node = v[j];
      ret -= (long long)(deg[node] - indeg[node]) * indeg[node];
      if (!vis[node]) {
        vis[node] = true;
        for (int anode : tdj[node]) {
          if (ch[anode] || cur[node] > cur[anode]) {
            continue;
          }
          ret -= indeg[anode];
          ++indeg[anode];
          ret += (deg[anode] - indeg[anode]);
        }
      }
      for (int anode : adj[node]) {
        if (cur[node] < cur[anode]) {
          ret -= indeg[anode];
          ++indeg[anode];
          ret += (deg[anode] - indeg[anode]);
        }
      }
      indeg[node] = 0;
      cur[node] = n + j;
      printf("%lld\n", ret);
    }
    i = ed + 1;
  }
}
int main() {
  solve();
  return 0;
}
