#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
const int N = 1e5;
const int M = 1e5;
int n, m, q;
vector<int> in[N + 1];
int z[N + 1];
long long ans;
inline long long get(int w) {
  return (long long)in[w].size() * (z[w] - in[w].size());
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u, v;
    u = read();
    v = read();
    if (u > v) swap(u, v);
    in[u].push_back(v);
    z[u]++;
    z[v]++;
  }
  for (int i = 1; i <= n; i++) ans += get(i);
  printf("%I64d\n", ans);
  q = read();
  for (int i = 1; i <= q; i++) {
    int c;
    c = read();
    ans -= get(c);
    for (int j = 0; j < in[c].size(); j++) {
      int d = in[c][j];
      ans -= get(d);
      in[d].push_back(c);
      ans += get(d);
    }
    in[c].clear();
    printf("%I64d\n", ans);
  }
  return 0;
}
