#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long ans = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }
int n, m, T;
struct node {
  int in, ou, w;
} a[maxn];
vector<int> g[maxn];
long long sum;
void gao(int s, int w) {
  sum -= 1ll * a[s].in * a[s].ou;
  for (auto t : g[s]) {
    g[t].push_back(s);
    sum -= 1ll * a[t].in * a[t].ou;
    a[s].in--;
    a[s].ou++;
    a[t].in++;
    a[t].ou--;
    sum += 1ll * a[t].in * a[t].ou;
  }
  g[s].clear();
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u < v) swap(u, v);
    g[v].push_back(u);
    a[u].ou++;
    a[v].in++;
  }
  for (int i = 1; i <= n; i++) {
    sum += 1ll * a[i].in * a[i].ou;
    a[i].w = i;
  }
  int q;
  cin >> q;
  cout << sum << "\n";
  for (int i = 1; i <= q; i++) {
    scanf("%d", &T);
    gao(T, i);
    printf("%I64d\n", sum);
  }
  return 0;
}
