#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000;
vector<int> in[N];
int dr[N];
long long ans;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (x < y) swap(x, y);
    in[y].push_back(x);
    dr[x]++;
    dr[y]++;
  }
  for (int i = 0; i < n; i++)
    ans += 1ll * (dr[i] - (int)in[i].size()) * (long long)in[i].size();
  cout << ans << "\n";
  int q;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    x--;
    ans -= 1ll * (dr[x] - (int)in[x].size()) * (long long)in[x].size();
    for (int i = 0; i < in[x].size(); i++) {
      int y = in[x][i];
      ans += (dr[y] - (int)in[y].size() - 1) - (int)in[y].size();
      in[y].push_back(x);
    }
    in[x].clear();
    cout << ans << "\n";
  }
  return 0;
}
