#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, q;
stack<int> graph[N];
pair<int, int> degrees[N];
long long prev_ans = 0;
long long preproc() {
  long long rval = 0;
  for (int i = 1; i <= n; ++i)
    rval += (long long)degrees[i].first * degrees[i].second;
  return rval;
}
long long query(int mwage) {
  prev_ans -= (long long)degrees[mwage].first * degrees[mwage].second;
  degrees[mwage].second += degrees[mwage].first;
  degrees[mwage].first = 0;
  if (!graph[mwage].empty()) {
    for (auto it = graph[mwage].top(); !graph[mwage].empty();) {
      prev_ans -= (long long)degrees[it].first * degrees[it].second;
      ++degrees[it].first;
      --degrees[it].second;
      prev_ans += (long long)degrees[it].first * degrees[it].second;
      graph[it].push(mwage);
      graph[mwage].pop();
      if (!graph[mwage].empty()) it = graph[mwage].top();
    }
  }
  return prev_ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int v = 0, u = 0;
    cin >> v >> u;
    graph[min(v, u)].push(max(v, u));
    ++degrees[min(v, u)].first;
    ++degrees[max(v, u)].second;
  }
  cin >> q;
  vector<long long> ans;
  prev_ans = preproc();
  ans.push_back(prev_ans);
  for (int i = 1; i <= q; ++i) {
    int cur = 0;
    cin >> cur;
    ans.push_back(query(cur));
  }
  for (auto val : ans) cout << val << endl;
}
