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