#include <bits/stdc++.h>
using namespace std;
inline void prnt(bool ok) { cout << (ok ? "YES" : "NO"); }
const int ppr = 257;
const long long INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 3e6 + 123;
const long double pi = 3.141592653589793238462643;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
long long n, m, a[N], b[N], q, cur;
vector<long long> g[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  while (m--) {
    long long x, y;
    cin >> x >> y;
    if (x < y) swap(x, y);
    g[y].push_back(x);
    a[x]++;
    b[y]++;
  }
  for (long long i = 1; i <= n; i++) cur += a[i] * b[i];
  cin >> q;
  cout << cur << '\n';
  while (q--) {
    long long x;
    cin >> x;
    cur -= a[x] * b[x];
    a[x] += g[x].size();
    b[x] = 0;
    for (auto to : g[x]) {
      cur -= a[to] * b[to];
      b[to]++;
      a[to]--;
      cur += a[to] * b[to];
      g[to].push_back(x);
    }
    g[x].clear();
    cout << cur << '\n';
  }
  return 0;
}
