#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> sal(n + 1), r_num(n + 1, 0), l_num(n + 1, 0);
  vector<vector<int> > rset(n + 1);
  for (int i = 1; i <= n; i++) sal[i] = i;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (b < a) swap(a, b);
    r_num[a]++;
    l_num[b]++;
    rset[a].push_back(b);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (long long)l_num[i] * (long long)r_num[i];
  }
  cout << ans << "\n";
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    sal[x] = n + 1 + i;
    for (int ii : rset[x]) {
      ans += l_num[ii] - r_num[ii] - 1;
      l_num[ii]--;
      r_num[ii]++;
      rset[ii].push_back(x);
    }
    ans -= (long long)l_num[x] * (long long)r_num[x];
    l_num[x] += r_num[x];
    r_num[x] = 0;
    rset[x].clear();
    cout << ans << "\n";
  }
  return 0;
}
