#include <bits/stdc++.h>
using namespace std;
int const INF = (int)1e9 + 1e3;
long long const INFL = (long long)1e18 + 1e6;
mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
uniform_int_distribution<long long> ll_distr;
long long rnd(long long a, long long b) {
  return ll_distr(tw) % (b - a + 1) + a;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vals(n);
  vector<vector<int>> graph(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    vals[a].second++;
    vals[b].first++;
    graph[a].push_back(b);
  }
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += (long long)vals[i].first * vals[i].second;
  }
  cout << sum << "\n";
  int q;
  cin >> q;
  vector<int> neibs;
  for (int i = 0; i < q; ++i) {
    int v;
    cin >> v;
    --v;
    for (int u : graph[v]) {
      sum -= (long long)vals[u].first * vals[u].second;
      --vals[u].first;
      ++vals[u].second;
      sum += (long long)vals[u].first * vals[u].second;
      graph[u].push_back(v);
    }
    sum -= (long long)vals[v].first * vals[v].second;
    vals[v].first += vals[v].second;
    vals[v].second = 0;
    graph[v].clear();
    cout << sum << "\n";
  }
}
int main() {
  cout << setprecision(15) << fixed;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_count = 1;
  for (int test = 1; test <= test_count; ++test) {
    solve();
  }
}
