#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const long long mod = 1000000007;
vector<int> v[N];
long long in[N], out[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m, q, x, y;
  long long ans = 0;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y;
    v[min(x, y)].push_back(max(x, y));
    in[max(x, y)]++;
    out[min(x, y)]++;
  }
  cin >> q;
  for (int i = 1; i <= n; i++) ans += out[i] * in[i];
  cout << ans << '\n';
  ;
  while (q--) {
    cin >> x;
    ans -= in[x] * out[x];
    in[x] += v[x].size();
    for (auto it : v[x]) {
      ans -= out[it];
      out[it]++;
      in[it]--;
      ans += in[it];
      v[it].push_back(x);
    }
    out[x] = 0;
    v[x].clear();
    cout << ans << '\n';
    ;
  }
  return 0;
}
