#include <bits/stdc++.h>
using namespace std;
const int CS = 300;
vector<int> g[100005];
int vert[100005], number[100005];
int small[100005], big[100005], posit[100005];
bool table[CS + 5][CS + 5], used[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) number[i] = i;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (int)g[i].size(); j++) {
      int u = g[i][j];
      if (number[u] < number[i])
        small[i]++;
      else
        big[i]++;
    }
    ans += (long long)big[i] * (long long)small[i];
  }
  cout << ans << '\n';
  int quer;
  cin >> quer;
  for (int i = 1; i <= quer; i++) cin >> vert[i];
  for (int rep = 1; rep <= (quer - 1) / CS + 1; rep++) {
    for (int i = 1; i <= CS; i++)
      for (int j = 1; j <= CS; j++) table[i][j] = false;
    int lef = (rep - 1) * CS + 1, rig = min(quer, rep * CS);
    for (int i = lef; i <= rig; i++)
      used[vert[i]] = true, posit[vert[i]] = i - lef + 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < (int)g[i].size(); j++) {
        int u = g[i][j];
        if (used[i] && used[u]) table[posit[i]][posit[u]] = true;
      }
    }
    for (int i = lef; i <= rig; i++) used[vert[i]] = false;
    for (int i = lef; i <= rig; i++) {
      if (!used[vert[i]]) {
        used[vert[i]] = true;
        ans -= (long long)big[vert[i]] * (long long)small[vert[i]];
        small[vert[i]] = (int)g[vert[i]].size(), big[vert[i]] = 0;
        for (int j = 0; j < (int)g[vert[i]].size(); j++) {
          int u = g[vert[i]][j];
          if (number[vert[i]] < number[u]) {
            ans -= (long long)small[u] * (long long)big[u];
            small[u]--, big[u]++;
            ans += (long long)small[u] * (long long)big[u];
          }
        }
        number[vert[i]] = i + n;
      } else {
        ans -= (long long)big[vert[i]] * (long long)small[vert[i]];
        big[vert[i]] = 0, small[vert[i]] = (int)g[vert[i]].size();
        for (int j = 1; j <= CS; j++)
          if (table[posit[vert[i]]][j]) {
            int u = vert[j + lef - 1];
            if (number[vert[i]] < number[u]) {
              ans -= (long long)small[u] * (long long)big[u];
              small[u]--, big[u]++;
              ans += (long long)small[u] * (long long)big[u];
            }
          }
        number[vert[i]] = i + n;
      }
      cout << ans << '\n';
    }
    for (int i = lef; i <= rig; i++) used[vert[i]] = false;
  }
  return 0;
}
