#include <bits/stdc++.h>
using namespace std;
const long long N = 4e5;
long long Res, d[N];
vector<long long> in[N];
long long calc(long long x) { return in[x].size() * (d[x] - in[x].size()); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    d[x]++;
    d[y]++;
    if (x > y) swap(x, y);
    in[x].push_back(y);
  }
  for (long long i = 1; i <= n; i++) Res += calc(i);
  cout << Res << "\n";
  long long q;
  cin >> q;
  while (q--) {
    long long t;
    cin >> t;
    Res -= calc(t);
    for (auto& i : in[t]) {
      Res -= calc(i);
      in[i].push_back(t);
      Res += calc(i);
    }
    in[t].clear();
    cout << Res << "\n";
  }
}
