#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<int> G[maxn];
long long n, m, rd[maxn];
int Read() {
  int num = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    num = (num << 3) + (num << 1) + ch - '0';
    ch = getchar();
  }
  return num;
}
int main() {
  n = Read();
  m = Read();
  for (int i = 0; i < m; ++i) {
    int a = Read();
    int b = Read();
    if (a > b) swap(a, b);
    G[a].push_back(b);
    rd[b]++;
  }
  long long res = 0;
  for (int i = 1; i <= n; ++i) res += G[i].size() * rd[i];
  cout << res << endl;
  m = Read();
  for (int i = 1; i <= m; ++i) {
    int a = Read();
    res -= G[a].size() * rd[a];
    for (int j = 0; j < G[a].size(); ++j) {
      int v = G[a][j];
      res -= rd[v] * G[v].size();
      rd[v]--;
      rd[a]++;
      G[v].push_back(a);
      res += G[v].size() * rd[v];
    }
    cout << res << endl;
    G[a].clear();
  }
  return 0;
}
