#include <bits/stdc++.h>
using namespace std;
struct __timestamper {};
vector<long long> fast(int n, vector<pair<int, int>> eed, vector<int> vv) {
  struct edge {
    int u, v;
    int pos_in, pos_out;
  };
  vector<edge> ed;
  for (auto o : eed) {
    if (o.first > o.second) swap(o.first, o.second);
    ed.push_back({o.first, o.second, -1, -1});
  }
  long long bad = 0;
  vector<int> val(n);
  iota(val.begin(), val.end(), 0);
  vector<vector<int>> in(n), out(n);
  auto add = [&](int id) {
    int u = ed[id].u;
    int v = ed[id].v;
    if (val[u] > val[v]) swap(u, v);
    ed[id].pos_in = in[u].size();
    ed[id].pos_out = out[v].size();
    in[u].push_back(id);
    out[v].push_back(id);
    bad += out[u].size();
    bad += in[v].size();
  };
  auto del = [&](int id) {
    int u = ed[id].u;
    int v = ed[id].v;
    if (val[u] > val[v]) swap(u, v);
    bad -= out[u].size();
    bad -= in[v].size();
    swap(in[u].back(), in[u][ed[id].pos_in]);
    ed[in[u][ed[id].pos_in]].pos_in = ed[id].pos_in;
    ed[id].pos_in = -1;
    in[u].pop_back();
    swap(out[v].back(), out[v][ed[id].pos_out]);
    ed[out[v][ed[id].pos_out]].pos_out = ed[id].pos_out;
    ed[id].pos_out = -1;
    out[v].pop_back();
  };
  for (int i = 0; i < (int)ed.size(); i++) {
    add(i);
  }
  vector<long long> ans;
  ans.push_back(bad);
  int cc = n;
  for (auto v : vv) {
    auto ids = in[v];
    for (int id : ids) del(id);
    val[v] = cc++;
    for (int id : ids) add(id);
    ans.push_back(bad);
  }
  return ans;
}
void print(vector<long long> v) {
  for (auto x : v) printf("%lld\n", x);
}
int main() {
  int n, m;
  bool first = 1;
  while (scanf("%d%d", &n, &m) == 2) {
    if (!first)
      printf("\n");
    else
      first = 0;
    vector<pair<int, int>> ed(m);
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &ed[i].first, &ed[i].second);
      ed[i].first--;
      ed[i].second--;
    }
    int q;
    scanf("%d", &q);
    vector<int> v(q);
    for (int i = 0; i < q; i++) {
      scanf("%d", &v[i]);
      v[i]--;
    }
    print(fast(n, ed, v));
  }
  return 0;
}
