#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
long long int powmod(long long int a, long long int b) {
  long long int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int nxt() {
  int x;
  cin >> x;
  return x;
}
vector<vector<int> > in;
vector<int> deg;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n = nxt(), m = nxt();
  in.assign(n, vector<int>());
  deg.assign(n, 0);
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m))) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    in[a].push_back(b);
    deg[a]++;
    deg[b]++;
  }
  long long int ans = 0;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    ans += 1LL * in[i].size() * (deg[i] - in[i].size());
  }
  printf("%lld\n", ans);
  int q = nxt();
  while (q--) {
    int x = nxt() - 1;
    ans -= 1LL * in[x].size() * (deg[x] - in[x].size());
    for (int y : in[x]) {
      ans -= 1LL * in[y].size() * (deg[y] - in[y].size());
      in[y].push_back(x);
      ans += 1LL * in[y].size() * (deg[y] - in[y].size());
    }
    in[x].clear();
    printf("%lld\n", ans);
  }
  return 0;
}
