#include <bits/stdc++.h>

using namespace std;

int n, m, q, ca[100005], cb[100005];
long long ans[100005];
bool cur[100005];
vector<int> b[100005];
vector<pair<int, int>> vv[100005];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int ta, tb;
		scanf("%d%d", &ta, &tb);
		if (ta > tb)
			swap(ta, tb);
		b[ta].push_back(tb);
		cb[ta]++;
		ca[tb]++;
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int tmp;
		scanf("%d", &tmp);
		vv[tmp].emplace_back(i, -b[tmp].size());
		for (int j : b[tmp]) {
			vv[j].emplace_back(i, 1);
			b[j].push_back(tmp);
		}
		b[tmp].clear();
	}
	for (int i = 1; i <= n; i++) {
		long long ta = ca[i], tb = cb[i];
		ans[0] += ta * tb;
		long long na = ta, nb = tb;
		for (int j = 0; j < vv[i].size(); j++) {
			nb += vv[i][j].second;
			na -= vv[i][j].second;
			ans[vv[i][j].first] += na * nb - ta * tb;
			ta = na;
			tb = nb;
		}
	}
	for (int i = 0; i <= q; i++) {
		printf("%lld\n", ans[i]);
		ans[i + 1] += ans[i];
	}
}


#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> ii;

int N, M, Q;
int keluar[100100];
vector<int> masuk[100100];
LL sum;
int main() {
	// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	// cin >> N >> M;
	scanf("%d %d", &N, &M);
	int u, v;
	for (int i = 0; i < M; i++) {
		// cin >> u >> v;
		scanf("%d %d", &u, &v);
		if (u > v) swap(u, v);
		keluar[v]++;
		masuk[u].pb(v);
	}

	for (int i = 1; i <= N; i++) {
		sum += keluar[i] * (LL)masuk[i].size();
	}

	// cout << sum << "\n";
	printf("%lld\n", sum);
	// cin >> Q;
	scanf("%d", &Q);
	while (Q--) {
		// cin >> v;
		scanf("%d", &v);
		sum -= keluar[v] * (LL)masuk[v].size();
		for (int u : masuk[v]) {
			sum -= keluar[u] * (LL)masuk[u].size();
			keluar[u]--;
			masuk[u].pb(v);
			sum += keluar[u] * (LL)masuk[u].size();

			keluar[v]++;
		}
		masuk[v].clear();

		// cout << sum << "\n";
		printf("%lld\n", sum);
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;

LL N, M, Q;
set<LL> masuk[100100];
set<LL> keluar[100100];
LL sum;
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> M;
	LL u, v;
	for (LL i = 0; i < M; i++) {
		cin >> u >> v;
		if (u > v) swap(u, v);
		keluar[v].insert(u);
		masuk[u].insert(v);
	}

	for (LL i = 1; i <= N; i++) {
		sum += (LL)keluar[i].size() * (LL)masuk[i].size();
	}

	cout << sum << "\n";
	cin >> Q;
	while (Q--) {
		cin >> v;
		vector<LL> neigh;
		for (auto u : masuk[v]) {
			sum -= (LL)keluar[u].size() * (LL)masuk[u].size();
			keluar[u].erase(v);
			masuk[u].insert(v);
			sum += (LL)keluar[u].size() * (LL)masuk[u].size();

			neigh.pb(u);
		}
		sum -= (LL)keluar[v].size() * (LL)masuk[v].size();
		for (LL u : neigh) {
			masuk[v].erase(u);
			keluar[v].insert(u);
		}

		cout << sum << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;

LL N, M, Q;
set<LL> masuk[100100];
set<LL> keluar[100100];
LL sum;
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> M;
	LL u, v;
	for (LL i = 0; i < M; i++) {
		cin >> u >> v;
		keluar[v].insert(u);
		masuk[u].insert(v);
	}

	for (LL i = 1; i <= N; i++) {
		sum += (LL)keluar[i].size() * (LL)masuk[i].size();
	}

	cout << sum << "\n";
	cin >> Q;
	while (Q--) {
		cin >> v;
		vector<LL> neigh;
		for (auto u : masuk[v]) {
			sum -= (LL)keluar[u].size() * (LL)masuk[u].size();
			keluar[u].erase(v);
			masuk[u].insert(v);
			sum += (LL)keluar[u].size() * (LL)masuk[u].size();

			neigh.pb(u);
		}
		sum -= (LL)keluar[v].size() * (LL)masuk[v].size();
		for (LL u : neigh) {
			masuk[v].erase(u);
			keluar[v].insert(u);
		}

		cout << sum << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;

LL N, M, Q;
set<LL> masuk[100100];
set<LL> keluar[100100];
LL sum;
int main() {
	// ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	// cin >> N >> M;
	scanf("%lld %lld", &N, &M);
	LL u, v;
	for (LL i = 0; i < M; i++) {
		// cin >> u >> v;
		scanf("%lld %lld", &u, &v);
		if (u > v) swap(u, v);
		keluar[v].insert(u);
		masuk[u].insert(v);
	}

	for (LL i = 1; i <= N; i++) {
		sum += (LL)keluar[i].size() * (LL)masuk[i].size();
	}

	// cout << sum << "\n";
	printf("%lld\n", sum);
	// cin >> Q;
	scanf("%lld", &Q);
	while (Q--) {
		// cin >> v;
		scanf("%lld", &v);
		sum -= (LL)keluar[v].size() * (LL)masuk[v].size();
		for (auto u : masuk[v]) {
			sum -= (LL)keluar[u].size() * (LL)masuk[u].size();
			keluar[u].erase(v);
			masuk[u].insert(v);
			sum += (LL)keluar[u].size() * (LL)masuk[u].size();

			keluar[v].insert(u);
		}
		masuk[v].clear();

		// cout << sum << "\n";
		printf("%lld\n", sum);
	}
	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

int n, m;
const int N = 210000;
vector<int> g[N];
ll d[N];
ll cal(int x) {
	return (ll)g[x].size() * (d[x] - g[x].size()) ;
}
int main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		int x = read(), y = read();
		if(x > y) swap(x, y);
		g[y].push_back(x);
		++d[x], ++d[y];
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++i) ans += cal(i);
	writeln(ans);
	int Q = read();
	while(Q--) {
		int x =read();
		while(!g[x].empty()) {
			int u = g[x].back();
			ans -= cal(u) + cal(x);
			g[x].pop_back();
			g[u].push_back(x);
			ans += cal(u) + cal(x);
		}
		writeln(ans);
	}
	writeln(ans);
	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

int n, m;
const int N = 210000;
vector<int> g[N];
ll d[N];
ll cal(int x) {
	return (ll)g[x].size() * (d[x] - g[x].size()) ;
}
int main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		int x = read(), y = read();
		if(x > y) swap(x, y);
		g[y].push_back(x);
		++d[x], ++d[y];
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++i) ans += cal(i);
	writeln(ans);
	int Q = read();
	while(Q--) {
		int x =read();
		while(!g[x].empty()) {
			int u = g[x].back();
			ans -= cal(u) + cal(x);
			g[x].pop_back();
			g[u].push_back(x);
			ans += cal(u) + cal(x);
		}
		writeln(ans);
	}
	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

int n, m;
const int N = 210000;
vector<int> g[N];
ll d[N];
ll cal(int x) {
	return (ll)g[x].size() * (d[x] - g[x].size()) ;
}
int main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		int x = read(), y = read();
		if(x < y) swap(x, y);
		g[y].push_back(x);
		++d[x], ++d[y];
	}
	ll ans = 0;
	for(int i = 1; i <= n; ++i) ans += cal(i);
	writeln(ans);
	int Q = read();
	while(Q--) {
		int x =read();
		while(!g[x].empty()) {
			int u = g[x].back();
			ans -= cal(u) + cal(x);
			g[x].pop_back();
			g[u].push_back(x);
			ans += cal(u) + cal(x);
		}
		writeln(ans);
	}
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_set<int> high[100005];
unordered_set<int> low[100005];
vector<ll> cost;

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      cost.resize(n);
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a>b) swap(a,b);
        high[a].insert(b);
        low[b].insert(a);
      }
      int q; cin >> q;
      ll ans = 0;
      rep(i, n) {
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';
      rep(i, q) {
        int v; cin >> v; v--;
        for(auto e: high[v]) {
          low[e].erase(v);
          high[e].insert(v);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }

        low[v].insert(all(high[v]));
        high[v].clear();
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100005];
unordered_set<int> high[100005];
unordered_set<int> low[100005];
vector<ll> cost;

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      cost.resize(n);
      rep(i, n) {
        graph[i].clear();
        high[i].clear();
        low[i].clear();
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      int q; cin >> q;
      ll ans = 0;
      rep(i, n) {
        for(auto e: graph[i]) {
          if (e > i) {
            high[i].insert(e);
          } else {
            low[i].insert(e);
          }
        }
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';
      rep(i, q) {
        int v; cin >> v; v--;
        for(auto e: high[v]) {
          low[e].erase(v);
          high[e].insert(v);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }

        low[v].insert(all(high[v]));
        high[v].clear();
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100005];
vector<int> now;
set<int> high[100005];
set<int> low[100005];
vector<ll> cost;

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      now.resize(n);
      cost.resize(n);
      rep(i, n) {
        graph[i].clear();
        high[i].clear();
        low[i].clear();
      }
      rep(i, n) {
        now[i] = i;
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      int q; cin >> q;
      ll ans = 0;
      rep(i, n) {
        for(auto e: graph[i]) {
          if (e > i) {
            high[i].insert(e);
          } else {
            low[i].insert(e);
          }
        }
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';
      int before = -1;

      rep(i, q) {
        int v; cin >> v; v--;
        if (v == before) {
          cout << ans << '\n';
          continue;
        }
        for(auto e: high[v]) {
          low[e].erase(v);
          high[e].insert(v);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }

        auto it = high[v].begin();
        while(it != high[v].end()) {
          low[v].insert(*it);
          it = high[v].erase(it);
        }
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
        before = v;
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100005];
vector<int> graph2[100005];
vector<int> now;
set<int> high[100005];
set<int> low[100005];
vector<ll> cost;
vector<bool> use(100005, true);

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      now.resize(n);
      cost.resize(n);
      rep(i, n) {
        graph[i].clear();
        graph2[i].clear();
        high[i].clear();
        low[i].clear();
      }
      rep(i, n) {
        now[i] = i;
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      int q; cin >> q;
      ll ans = 0;
      rep(i, n) {
        if (graph[i].size() < 2) {
          use[i] = false;
          continue;
        }
        for(auto e: graph[i]) {
          if (e > i) {
            high[i].insert(e);
          } else {
            low[i].insert(e);
          }
        }
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';
      int before = -1;

      rep(i, n) {
        for(auto e: graph[i]) {
          if (use[e]) {
            graph2[i].push_back(e);
          }
        }
      }

      rep(i, q) {
        int money = n+i;
        int v; cin >> v; v--;
        if (v == before) {
          cout << ans << '\n';
          continue;
        }
        for(auto e: graph2[v]) {
          if (!use[e]) continue;
          low[e].erase(now[v]);
          high[e].erase(now[v]);
          high[e].insert(money);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }
        now[v] = money;
        auto it = high[v].begin();
        while(it != high[v].end()) {
          low[v].insert(*it);
          it = high[v].erase(it);
        }
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
        before = v;
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_set<int> high[100005];
unordered_set<int> low[100005];
vector<ll> cost;

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      cost.resize(n);
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a>b) swap(a,b);
        high[a].insert(b);
        low[b].insert(a);
      }
      ll ans = 0;
      rep(i, n) {
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';

      int q; cin >> q;
      while(q--) {
        int v; cin >> v; v--;
        for(auto& e: high[v]) {
          low[e].erase(v);
          high[e].insert(v);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }

        low[v].insert(all(high[v]));
        high[v].clear();
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> high[100005];
vector<int> deg;
vector<ll> cost;

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      deg.resize(n);
      cost.resize(n);
      rep(i, n) {
        deg[i] = 0;
        high[i].clear();
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a>b) swap(a,b);
        high[a].push_back(b);
        deg[a]++; deg[b]++;
      }
      ll ans = 0;
      rep(i, n) {
        cost[i] = high[i].size() * (deg[i] - high[i].size());
        ans += cost[i];
      }
      cout << ans << '\n';

      int q; cin >> q;
      while(q--) {
        int v; cin >> v; v--;
        for(auto& e: high[v]) {
          high[e].push_back(v);
          ll c = (deg[e] - high[e].size()) * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }
        high[v].clear();
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100005];
vector<int> now;
set<int> high[100005];
set<int> low[100005];
vector<ll> cost;
vector<bool> use(100005, true);

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      now.resize(n);
      cost.resize(n);
      rep(i, n) {
        graph[i].clear();
        high[i].clear();
        low[i].clear();
      }
      rep(i, n) {
        now[i] = i;
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      int q; cin >> q;
      ll ans = 0;
      rep(i, n) {
        if (graph[i].size() < 2) {
          use[i] = false;
          continue;
        }
        for(auto e: graph[i]) {
          if (e > i) {
            high[i].insert(e);
          } else {
            low[i].insert(e);
          }
        }
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';
      int before = -1;
      rep(i, q) {
        int money = n+i;
        int v; cin >> v; v--;
        if (v == before) {
          cout << ans << '\n';
          continue;
        }
        for(auto e: graph[v]) {
          if (!use[e]) continue;
          low[e].erase(now[v]);
          high[e].erase(now[v]);
          high[e].insert(money);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }
        now[v] = money;
        auto it = high[v].begin();
        while(it != high[v].end()) {
          low[v].insert(*it);
          it = high[v].erase(it);
        }
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
        before = v;
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_set<int> high[100005];
unordered_set<int> low[100005];
ll cost[100005];

class CKonradAndCompanyEvaluation {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a>b) swap(a,b);
        high[a].insert(b);
        low[b].insert(a);
      }
      ll ans = 0;
      rep(i, n) {
        cost[i] = high[i].size() * low[i].size();
        ans += cost[i];
      }
      cout << ans << '\n';

      int q; cin >> q;
      while(q--) {
        int v; cin >> v; v--;
        for(auto& e: high[v]) {
          low[e].erase(v);
          high[e].insert(v);
          ll c = low[e].size() * high[e].size();
          ans += (c-cost[e]);
          cost[e] = c;
        }

        low[v].insert(all(high[v]));
        high[v].clear();
        ans -= cost[v];
        cost[v] = 0;
        cout << ans << '\n';
      }
    }
};

signed main() {
  CKonradAndCompanyEvaluation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[100010];
int A[100010];
ll cntsmall[100010];
ll cntlarge[100010];
int val[100010];
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/

	int N, M; //cin >> N >> M;
	scanf("%d%d", &N, &M);
	REP(i, N) {
		A[i] = i;
	}
	int u, v;
	REP(i, M) {
		// cin >> u >> v;
		scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v); G[v].pb(u);
		int mn = min(u, v),mx = max(u, v);
		cntsmall[mx]++;
		cntlarge[mn]++;
	}
	ll ans = 0;
	/*REP(i, N) {
		for (auto to : G[i]) {
			if (A[to] < A[i])cntsmall[i]++;
			else cntlarge[i]++;
		}
	}*/
	REP(i, N) {
		ans += cntlarge[i] * cntsmall[i];
	}
	int Q; //cin >> Q;
	scanf("%d", &Q);
	REP(i, Q) {
		//cin >> v[i];
		scanf("%d", &val[i]);
		val[i]--;
	}
	printf("%lld\n", ans);

	REP(i, Q) {
		int nex = val[i];
		ll cnt2 = cntlarge[nex] * cntsmall[nex];
		int cnt1 = 0;
		int cnt3 = 0;
		for (auto to : G[nex]) {
			if (A[to] < A[nex]) {
				cnt1 += cntsmall[to];
			}
			else {
				cnt3 += cntlarge[to];
			}
		}
		ans -= (cnt1 + cnt2 + cnt3);
		for (auto to : G[nex]) {
			if (A[to] > A[nex]) {
				cntsmall[to]--;
				cntlarge[to]++;
				//ans += cntsmall[to];
			}
		}
		cntlarge[nex] = 0;
		cntsmall[nex] = G[nex].size();
		for (auto to : G[nex]) {
			ans += cntsmall[to];
		}
		A[nex] = N + i;

		printf("%lld\n", ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	REP(i, Q) {
		int pos = v[i];
		auto itr = Ls[pos].begin();
		int cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e7) {
				return 1;
			}
			int to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	int to = 0;
	int pos = 0;
	int cnt_small = 0;
	REP(i, Q) {
		pos = v[i];
		auto itr = Ls[pos].begin();
		cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e7) {
				return 1;
			}
			to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[100010];
int v[100010];
int deg[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		deg[u]++, deg[v]++;
		G[mn].pb(mx);
	}
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	ll ans = 0;
	REP(i, N) {
		ans += (deg[i] - G[i].size())*G[i].size();
	}
	print(ans);
	REP(i, Q) {
		int pos = v[i];
		ans -= (deg[pos] - G[pos].size())*G[pos].size();
		for (auto to : G[pos]) {
			ans -= G[to].size();
			ans += (deg[to] - G[to].size()-1);
			G[to].pb(pos);
		}
		G[pos].clear();
		print(ans);
	}
}


#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[100010];
int A[100010];
int cntsmall[100010];
int cntlarge[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, N) {
		A[i] = i;
	}
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].pb(v); G[v].pb(u);
		int mn = min(u, v),mx = max(u, v);
		cntsmall[mx]++;
		cntlarge[mn]++;
	}
	int ans = 0;
	/*REP(i, N) {
		for (auto to : G[i]) {
			if (A[to] < A[i])cntsmall[i]++;
			else cntlarge[i]++;
		}
	}*/
	REP(i, N) {
		ans += cntlarge[i] * cntsmall[i];
	}
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	print(ans);

	REP(i, Q) {
		int nex = v[i];
		int cnt2 = cntlarge[nex] * cntsmall[nex];
		int cnt1 = 0;
		int cnt3 = 0;
		for (auto to : G[nex]) {
			if (A[to] < A[nex]) {
				cnt1 += cntsmall[to];
			}
			else {
				cnt3 += cntlarge[to];
			}
		}
		ans -= (cnt1 + cnt2 + cnt3);
		for (auto to : G[nex]) {
			if (A[to] > A[nex]) {
				cntsmall[to]--;
				cntlarge[to]++;
			}
		}
		A[nex] = N + i;
		cntlarge[nex] = 0;
		cntsmall[nex] = G[nex].size();
		for (auto to : G[nex]) {
			ans += cntsmall[to];
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	REP(i, Q) {
		int pos = v[i];
		auto itr = Ls[pos].begin();
		int cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>2e7) {
				return 1;
			}
			int to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	int to = 0;
	int pos = 0;
	int cnt_small = 0;
	auto itr = Ls[0].begin();
	REP(i, Q) {
		pos = v[i];
		itr = Ls[pos].begin();
		cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e7) {
				return 1;
			}
			to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010],Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,M;cin>>N>>M;
    REP(i,M){
        int u,v;cin>>u>>v;u--,v--;
        int mx=max(u,v),mn=min(u,v);
        Ss[mx].insert(mn);Ls[mn].insert(mx);
    }
    ll ans=0;
    int Q;cin>>Q;
    REP(i,Q){
        cin>>v[i];v[i]--;
    }
    REP(i,N){
        ans+=Ss[i].size()*Ls[i].size();
    }
    print(ans);
    REP(i,Q){
        int pos=v[i];
        auto itr=Ls[pos].begin();
        int cnt_small=Ss[pos].size();
        while(itr!=Ls[pos].end()){
            int to=*itr;
            ans-=Ls[to].size();
            ans-=cnt_small;
            itr=Ls[pos].erase(itr);
            Ss[pos].insert(to);
            Ss[to].erase(pos);
            Ls[to].insert(pos);
            ans+=Ss[to].size();
        }
        print(ans);
    }
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	REP(i, Q) {
		int pos = v[i];
		auto itr = Ls[pos].begin();
		int cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e8) {
				return 1;
			}
			int to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[100010];
int A[100010];
int cntsmall[100010];
int cntlarge[100010];
int val[100010];
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/

	int N, M; //cin >> N >> M;
	scanf("%d%d", &N, &M);
	REP(i, N) {
		A[i] = i;
	}
	int u, v;
	REP(i, M) {
		// cin >> u >> v;
		scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v); G[v].pb(u);
		int mn = min(u, v),mx = max(u, v);
		cntsmall[mx]++;
		cntlarge[mn]++;
	}
	ll ans = 0;
	/*REP(i, N) {
		for (auto to : G[i]) {
			if (A[to] < A[i])cntsmall[i]++;
			else cntlarge[i]++;
		}
	}*/
	REP(i, N) {
		ans += (ll)cntlarge[i] * cntsmall[i];
	}
	int Q; //cin >> Q;
	scanf("%d", &Q);
	REP(i, Q) {
		//cin >> v[i];
		scanf("%d", &val+i);
		val[i]--;
	}
	printf("%lld\n", ans);

	REP(i, Q) {
		int nex = val[i];
		int cnt2 = cntlarge[nex] * cntsmall[nex];
		int cnt1 = 0;
		int cnt3 = 0;
		for (auto to : G[nex]) {
			if (A[to] < A[nex]) {
				cnt1 += cntsmall[to];
			}
			else {
				cnt3 += cntlarge[to];
			}
		}
		ans -= (cnt1 + cnt2 + cnt3);
		for (auto to : G[nex]) {
			if (A[to] > A[nex]) {
				cntsmall[to]--;
				cntlarge[to]++;
				ans += cntsmall[to];
			}
			else {
				ans += cntsmall[to];
			}
		}
		A[nex] = N + i;
		cntlarge[nex] = 0;
		cntsmall[nex] = G[nex].size();
		printf("%lld\n", ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	REP(i, Q) {
		int pos = v[i];
		auto itr = Ls[pos].begin();
		int cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>5e7) {
				return 1;
			}
			int to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

//vector<int>Ss[100010],Ls[100010];
unordered_set<int>Ss[100010],Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,M;cin>>N>>M;
    REP(i,M){
        int u,v;cin>>u>>v;u--,v--;
        int mx=max(u,v),mn=min(u,v);
        //Ss[mx].pb(mn);Ls[mn].pb(mx);
        Ss[mx].insert(mn);Ls[mn].insert(mx);
    }
    ll ans=0;
    int Q;cin>>Q;
    REP(i,Q){
        cin>>v[i];v[i]--;
    }
    REP(i,N){
        ans+=Ss[i].size()*Ls[i].size();
    }
    print(ans);
    REP(i,Q){
        int pos=v[i];
        auto itr=Ls[pos].begin();
        int cnt_small=Ss[pos].size();
        while(itr!=Ls[pos].end()){
            int to=*itr;
            ans-=Ls[to].size();
            ans-=cnt_small;
            itr=Ls[pos].erase(itr);
            Ss[pos].insert(to);
            Ss[to].erase(pos);
            Ls[to].insert(pos);
            ans+=Ss[to].size();
        }
        //auto itr2=Ss[pos].begin();
        // while(itr2!=Ss[pos].end()){
        //     int to=*itr2;
        //     ans+=Ss[to].size();
        //     itr2++;
        // }
        print(ans);
    }
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	REP(i, Q) {
		int pos = v[i];
		auto itr = Ls[pos].begin();
		int cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e7) {
				return 1;
			}
			int to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010],Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,M;cin>>N>>M;
    REP(i,M){
        int u,v;cin>>u>>v;u--,v--;
        int mx=max(u,v),mn=min(u,v);
        Ss[mx].insert(mn);Ls[mn].insert(mx);
    }
    ll ans=0;
    int Q;cin>>Q;
    REP(i,Q){
        cin>>v[i];v[i]--;
    }
    REP(i,N){
        ans+=Ss[i].size()*Ls[i].size();
    }
    print(ans);
    int cnt=0;
    REP(i,Q){
        int pos=v[i];
        auto itr=Ls[pos].begin();
        int cnt_small=Ss[pos].size();
        while(itr!=Ls[pos].end()){
            cnt++;
            if(cnt>1e8){
                return 1;
            }
            int to=*itr;
            ans-=Ls[to].size();
            ans-=cnt_small;
            itr=Ls[pos].erase(itr);
            Ss[pos].insert(to);
            Ss[to].erase(pos);
            Ls[to].insert(pos);
            ans+=Ss[to].size();
        }
        print(ans);
    }
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

unordered_set<int>Ss[100010], Ls[100010];
int v[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v; u--, v--;
		int mx = max(u, v), mn = min(u, v);
		Ss[mx].insert(mn); Ls[mn].insert(mx);
	}
	ll ans = 0;
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	REP(i, N) {
		ans += Ss[i].size()*Ls[i].size();
	}
	print(ans);
	int cnt = 0;
	int to = 0;
	int pos = 0;
	int cnt_small = 0;
	auto itr = Ls[0].begin();
	REP(i, Q) {
		pos = v[i];
		itr = Ls[pos].begin();
		cnt_small = Ss[pos].size();
		while (itr != Ls[pos].end()) {
			cnt++;
			if (cnt>1e7) {
				return 1;
			}
			to = *itr;
			ans -= Ls[to].size();
			ans -= cnt_small;
			itr = Ls[pos].erase(itr);
			Ss[pos].insert(to);
			Ss[to].erase(pos);
			Ls[to].insert(pos);
			ans += Ss[to].size();
		}
		print(ans);
	}
}


//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

set<int>Ss[100010],Ls[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N,M;cin>>N>>M;
    REP(i,M){
        int u,v;cin>>u>>v;u--,v--;
        int mx=max(u,v),mn=min(u,v);
        Ss[mx].insert(mn);Ls[mn].insert(mx);
    }
    ll ans=0;
    int Q;cin>>Q;
    REP(i,Q){
        cin>>v[i];v[i]--;
    }
    REP(i,N){
        ans+=Ss[i].size()*Ls[i].size();
    }
    print(ans);
    REP(i,Q){
        int pos=v[i];
        auto itr=Ls[pos].begin();
        int cnt_small=Ss[pos].size();
        while(itr!=Ls[pos].end()){
            int to=*itr;
            ans-=Ls[to].size();
            ans-=cnt_small;
            itr=Ls[pos].erase(itr);
            Ss[pos].insert(to);
            Ss[to].erase(pos);
            Ls[to].insert(pos);
            ans+=Ss[to].size();
        }
        print(ans);
    }
}


#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a>b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a<b) a = b; }

const int MOD = 1e9+7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>G[100010];
int A[100010];
int cntsmall[100010];
int cntlarge[100010];
int v[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M; cin >> N >> M;
	REP(i, N) {
		A[i] = i;
	}
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].pb(v); G[v].pb(u);
	}
	int ans = 0;
	REP(i, N) {
		for (auto to : G[i]) {
			if (A[to] < A[i])cntsmall[i]++;
			else cntlarge[i]++;
		}
	}
	REP(i, N) {
		for (auto to : G[i]) {
			if (A[to] < A[i]) {
				ans += cntsmall[to];
			}
		}
	}
	int Q; cin >> Q;
	REP(i, Q) {
		cin >> v[i]; v[i]--;
	}
	print(ans);

	REP(i, Q) {
		int nex = v[i];
		int cnt2 = cntlarge[nex] * cntsmall[nex];
		int cnt1 = 0;
		int cnt3 = 0;
		for (auto to : G[nex]) {
			if (A[to] < A[nex]) {
				cnt1 += cntsmall[to];
			}
			else {
				cnt3 += cntlarge[to];
			}
		}
		ans -= (cnt1 + cnt2 + cnt3);
		for (auto to : G[nex]) {
			if (A[to] > A[nex]) {
				cntsmall[to]--;
				cntlarge[to]++;
			}
		}
		A[nex] = N + i;
		cntlarge[nex] = 0;
		cntsmall[nex] = G[nex].size();
		for (auto to : G[nex]) {
			ans += cntsmall[to];
		}
		print(ans);
	}
}


#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/CLionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/CLionProjects/ACM/output.txt", "w", stdout);
//freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0) {
    if (rl.rlim_cur < kStackSize) {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0) {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  start = clock();
  int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif
  cout.precision(20);
  cout << fixed;
  //cin >> t;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();

#ifdef AIM1
  while (true) {
    solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif
  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

mt19937 rng((unsigned long long)chrono::steady_clock::now().time_since_epoch().count());

void precalc() {

}

//#define int li
//const li mod = 1000000007;
//const int mod = 998244353;
//using ull = unsigned long long;

struct SegTree {
  int shift = 1;
  vector<li> tree;
  SegTree(int n) {
    while (shift < n) {
      shift *= 2;
    }
    tree.assign(2 * shift, 0LL);
  }
  li get_res(int l, int r) {
    l += shift;
    r += shift;
    li res = 0;
    while (l < r) {
      if (l & 1) {
        res += tree[l];
        ++l;
        continue;
      }
      if (r & 1) {
        --r;
        res += tree[r];
        continue;
      }
      l /= 2;
      r /= 2;
    }
    return res;
  }
  void update(int v, li val) {
    v += shift;
    tree[v] = val;
    v /= 2;
    while (v > 0) {
      tree[v] = tree[2 * v] + tree[2 * v + 1];
      v /= 2;
    }
  }
};

void solve(__attribute__((unused)) bool read) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> initial_left(n, 0), initial_right(n, 0);
  vector<vector<int>> edges_to_right(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    if (a > b) {
      swap(a, b);
    }
    g[a].push_back(b);
    g[b].push_back(a);
    ++initial_left[b];
    ++initial_right[a];
    edges_to_right[a].push_back(b);
  }
  int Q;
  cin >> Q;
  li res = 0;
  SegTree left_tree(n + Q + 1);
  for (int i = 0; i < n; ++i) {
    res += initial_left[i] * 1LL * initial_right[i];
    left_tree.update(i, initial_left[i]);
  }
  vector<int> current_pos(n);
  iota(all(current_pos), 0);
  cout << res << "\n";
  for (int w = 0; w < Q; ++w) {
    int v;
    cin >> v;
    --v;
    int pos = current_pos[v];
    int to_lef = initial_left[pos], to_rig = initial_right[pos];
    res -= to_lef * 1LL * to_rig;
    res -= left_tree.get_res(0, pos);

    for (int to : edges_to_right[v]) {
      res -= initial_right[current_pos[to]];
      --initial_left[current_pos[to]];
      left_tree.update(current_pos[to], initial_left[current_pos[to]]);
      ++initial_right[current_pos[to]];
      edges_to_right[to].push_back(v);
    }
    edges_to_right[v].clear();
    initial_left[pos] = initial_right[pos] = 0;
    left_tree.update(pos, initial_left[pos]);
    int n_edges = g[v].size();
    initial_left.push_back(n_edges);
    int new_pos = n + w;
    left_tree.update(new_pos, initial_left[new_pos]);
    res += left_tree.get_res(0, new_pos);
    current_pos[v] = new_pos;
    initial_right.push_back(0);

    /*for (int i = 0; i < n; ++i) {
      int pos = current_pos[i];
      cout << "val: " << i <<  " pos: " << pos << " lef: " << initial_left[pos] <<
           " rig: " << initial_right[pos] << endl;
    }*/

    cout << res << "\n";
  }

}


#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/CLionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/CLionProjects/ACM/output.txt", "w", stdout);
//freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0) {
    if (rl.rlim_cur < kStackSize) {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0) {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  start = clock();
  int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif
  cout.precision(20);
  cout << fixed;
  //cin >> t;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();

#ifdef AIM1
  while (true) {
    solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif
  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

mt19937 rng((unsigned long long)chrono::steady_clock::now().time_since_epoch().count());

void precalc() {

}

//#define int li
//const li mod = 1000000007;
//const int mod = 998244353;
//using ull = unsigned long long;

void solve(__attribute__((unused)) bool read) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> initial_left(n, 0), initial_right(n, 0);
  vector<vector<int>> edges_to_right(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    if (a > b) {
      swap(a, b);
    }
    g[a].push_back(b);
    g[b].push_back(a);
    ++initial_left[b];
    ++initial_right[a];
    edges_to_right[a].push_back(b);
  }
  int Q;
  cin >> Q;

  li res = 0;

  auto make_inc = [&] (bool add, int pos) {
    auto val = initial_left[pos] * 1LL * initial_right[pos];
    if (add) {
      res += val;
    } else {
      res -= val;
    }
  };

  for (int i = 0; i < n; ++i) {
    make_inc(true, i);
  }

  vector<int> current_pos(n);
  iota(all(current_pos), 0);
  cout << res << "\n";
  for (int w = 0; w < Q; ++w) {
    int v;
    cin >> v;
    --v;
    int pos = current_pos[v];

    for (int to : edges_to_right[v]) {
      make_inc(false, current_pos[to]);
      --initial_left[current_pos[to]];
      ++initial_right[current_pos[to]];
      make_inc(true, current_pos[to]);

      edges_to_right[to].push_back(v);
    }
    edges_to_right[v].clear();

    make_inc(false, pos);
    initial_left[pos] = initial_right[pos] = 0;

    int n_edges = g[v].size();
    initial_left.push_back(n_edges);

    int new_pos = n + w;
    current_pos[v] = new_pos;
    initial_right.push_back(0);

    cout << res << "\n";
  }

}


#include <bits/stdc++.h>
using namespace std;
int deg[100001];
vector<int> g[100001];
int main(){
    int n, m, q;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        if(a > b) swap(a, b);
        g[a].push_back(b);
        deg[a]++;
        deg[b]++;
    }

    long long ans = 0;
    for(int i=1;i<=n;i++) ans += (deg[i]-g[i].size())*1ll*g[i].size();
    printf("%lld\n", ans);

    scanf("%d", &q);
    while(q--){
        int u;
        scanf("%d", &u);
        ans -= (deg[u]-g[u].size())*1ll*g[u].size();
        for(int j=0;j<g[u].size();j++){
            int v = g[u][j];
            ans -= (deg[v]-g[v].size())*1ll*g[v].size();
            g[v].push_back(u);
            ans += (deg[v]-g[v].size())*1ll*g[v].size();
        }
        g[u].clear();
        printf("%lld\n", ans);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int deg[100001], a[100001], b[100001], idx[100001], in[100001], out[100001];
vector<pii> v;

vector<int> g[100001];
vector<int> g2[100001];
int val[100001];
int main(){
    int n, m, q;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        scanf("%d%d", &a[i], &b[i]);
        deg[a[i]]++;
        deg[b[i]]++;
    }
    for(int i=1;i<=n;i++){
        v.push_back(pii(deg[i], i));
        val[i] = i;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for(int i=0;i<v.size();i++){
        int j = v[i].second;
        idx[j] = i;
    }

    long long ans = 0;
    for(int i=1;i<=m;i++){
        if(idx[a[i]] > idx[b[i]]) swap(a[i], b[i]);
        g[b[i]].push_back(a[i]);
        if(b[i] > a[i]) g2[a[i]].push_back(b[i]);

        if(a[i] > b[i]){
            in[a[i]]++;
            out[b[i]]++;
        }
        else{
            in[b[i]]++;
            out[a[i]]++;
        }
    }
    for(int i=1;i<=n;i++) ans += in[i]*1ll*out[i];

    printf("%lld\n", ans);
    scanf("%d", &q);
    for(int i=1;i<=q;i++){
        int u;
        scanf("%d", &u);
        for(int j=0;j<g[u].size();j++){
            int v = g[u][j];

            if(val[v] > val[u]){
                ans -= in[v]*1ll*out[v];
                ans -= in[u]*1ll*out[u];

                in[v]--;
                out[v]++;

                out[u]--;
                in[u]++;

                ans += in[v]*1ll*out[v];
                ans += in[u]*1ll*out[u];
                g2[v].push_back(u);
            }
        }
        for(int j=0;j<g2[u].size();j++){
            int v = g2[u][j];
            if(val[v] > val[u]){
                ans -= in[v]*1ll*out[v];
                ans -= in[u]*1ll*out[u];

                in[v]--;
                out[v]++;

                out[u]--;
                in[u]++;

                ans += in[v]*1ll*out[v];
                ans += in[u]*1ll*out[u];
            }
        }
        g2[u].clear();
        val[u] = n+i;
        printf("%lld\n", ans);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int deg[100001], a[100001], b[100001], idx[100001], in[100001], out[100001];
vector<pii> v;

vector<int> g[100001];
vector<int> g2[100001];
int val[100001];
int main(){
    int n, m, q;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        scanf("%d%d", &a[i], &b[i]);
        deg[a[i]]++;
        deg[b[i]]++;
    }
    for(int i=1;i<=n;i++){
        v.push_back(pii(deg[i], i));
        val[i] = i;
    }
    sort(v.begin(), v.end());
    for(int i=0;i<v.size();i++){
        int j = v[i].second;
        idx[j] = i;
    }

    long long ans = 0;
    for(int i=1;i<=m;i++){
        if(idx[a[i]] > idx[b[i]]) swap(a[i], b[i]);
        g[b[i]].push_back(a[i]);
        if(b[i] > a[i]) g2[a[i]].push_back(b[i]);

        if(a[i] > b[i]){
            in[a[i]]++;
            out[b[i]]++;
        }
        else{
            in[b[i]]++;
            out[a[i]]++;
        }
    }
    for(int i=1;i<=n;i++) ans += in[i]*1ll*out[i];

    printf("%lld\n", ans);
    scanf("%d", &q);
    for(int i=1;i<=q;i++){
        int u;
        scanf("%d", &u);
        for(int j=0;j<g[u].size();j++){
            int v = g[u][j];

            if(val[v] > val[u]){
                ans -= in[v]*1ll*out[v];
                ans -= in[u]*1ll*out[u];

                in[v]--;
                out[v]++;

                out[u]--;
                in[u]++;

                ans += in[v]*1ll*out[v];
                ans += in[u]*1ll*out[u];
                g2[v].push_back(u);
            }
        }
        for(int j=0;j<g2[u].size();j++){
            int v = g2[u][j];
            if(val[v] > val[u]){
                ans -= in[v]*1ll*out[v];
                ans -= in[u]*1ll*out[u];

                in[v]--;
                out[v]++;

                out[u]--;
                in[u]++;

                ans += in[v]*1ll*out[v];
                ans += in[u]*1ll*out[u];
            }
        }
        g2[u].clear();
        val[u] = n+i;
        printf("%lld\n", ans);
    }
}


#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

const int maxn = 100001;

int n, m;
int ind[maxn];
vector<int> r[maxn];
long long ans;

long long cal(int u);

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		r[u].push_back(v);
		ind[u]++;
		ind[v]++;
	}
	for (int i = 1; i <= n; i++) {
		ans += cal(i);
	}
	printf("%lld\n", ans);
	int q;
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int v;
		scanf("%d", &v);
		ans -= cal(v);
		for (int u : r[v]) {
			ans -= cal(u);
			r[u].push_back(v);
			ans += cal(u);
		}
		r[v].clear();
		printf("%lld\n", ans);
	}
	return 0;
}

long long cal(int u) {
	return (long long)(ind[u] - r[u].size()) * r[u].size();
}


#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

const int maxn = 100001;

int n, m;
int ind[maxn];
set<int> r[maxn];
long long ans;

long long cal(int u);

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		r[u].insert(v);
		ind[u]++;
		ind[v]++;
	}
	for (int i = 1; i <= n; i++) {
		ans += cal(i);
	}
	printf("%lld\n", ans);
	int q;
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int v;
		scanf("%d", &v);
		ans -= cal(v);
		for (int u : r[v]) {
			ans -= cal(u);
			r[u].insert(v);
			ans += cal(u);
		}
		r[v].clear();
		printf("%lld\n", ans);
	}
	return 0;
}

long long cal(int u) {
	return (long long)(ind[u] - r[u].size()) * r[u].size();
}


#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

const int maxn = 100001;

int n, m;
set<int> l[maxn], r[maxn];
long long ans;

long long cal(int u);

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		l[v].insert(u);
		r[u].insert(v);
	}
	for (int i = 1; i <= n; i++) {
		ans += cal(i);
	}
	printf("%lld\n", ans);
	int q;
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int v;
		scanf("%d", &v);
		ans -= cal(v);
		for (int u : r[v]) {
			ans -= cal(u);
			l[u].erase(v);
			r[u].insert(v);
			ans += cal(u);
			l[v].insert(u);
		}
		r[v].clear();
		printf("%lld\n", ans);
	}
	return 0;
}

long long cal(int u) {
	return (long long)l[u].size() * r[u].size();
}


#include <bits/stdc++.h>

using namespace std;
vector<int> sz[100001];
int szom[100001];
int db[100001];
int n, m, q;
int ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=1; i<=m; i++) {
        int a, b;
        cin >> a >> b;
        if (b>a) {
            swap(a, b);
            sz[b].push_back(a);
            db[b]++;
            szom[a]++, szom[b]++;
        }
    }
    for (int i=1; i<=n; i++) {
        ans+=db[i]*(szom[i]-db[i]);
    }
    cout << ans << "\n";
    cin >> q;
    for (int i=1; i<=q; i++) {
        int x;
        cin >> x;
        for (int i=0; i<sz[x].size(); i++) {
            int a=sz[x][i];
            db[a]++;
            sz[a].push_back(x);
            ans+=szom[a]+1;
            ans-=2*db[a];
        }
        ans-=db[x]*(szom[x]-db[x]);
        db[x]=0;
        sz[x].clear();
        cout << ans << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
vector<long long> sz[100001];
long long szom[100001];
long long db[100001];
long long n, m, q;
long long ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (long long i=1; i<=m; i++) {
        long long a, b;
        cin >> a >> b;
        if (b>a) {
            swap(a, b);
        }
        sz[b].push_back(a);
        db[b]++;
        szom[a]++, szom[b]++;
        }
    }
    for (long long i=1; i<=n; i++) {
        ans+=db[i]*(szom[i]-db[i]);
    }
    cout << ans << "\n";
    cin >> q;
    for (long long i=1; i<=q; i++) {
        long long x;
        cin >> x;
        for (long long i=0; i<sz[x].size(); i++) {
            long long a=sz[x][i];
            db[a]++;
            sz[a].push_back(x);
            ans+=szom[a]+1;
            ans-=2*db[a];
        }
        ans-=db[x]*(szom[x]-db[x]);
        db[x]=0;
        sz[x].clear();
        cout << ans << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
vector<long long> sz[100001];
long long szom[100001];
long long db[100001];
long long n, m, q;
long long ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (long long i=1; i<=m; i++) {
        long long a, b;
        cin >> a >> b;
        if (b>a) {
            swap(a, b);
        }
        sz[b].push_back(a);
        db[b]++;
        szom[a]++, szom[b]++;
    }
    for (long long i=1; i<=n; i++) {
        ans+=db[i]*(szom[i]-db[i]);
    }
    cout << ans << "\n";
    cin >> q;
    for (long long i=1; i<=q; i++) {
        long long x;
        cin >> x;
        for (long long i=0; i<sz[x].size(); i++) {
            long long a=sz[x][i];
            db[a]++;
            sz[a].push_back(x);
            ans+=szom[a]+1;
            ans-=2*db[a];
        }
        ans-=db[x]*(szom[x]-db[x]);
        db[x]=0;
        sz[x].clear();
        cout << ans << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
vector<long long> sz[100001];
long long szom[100001];
long long db[100001];
long long n, m, q;
long long ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (long long i=1; i<=m; i++) {
        long long a, b;
        cin >> a >> b;
        if (b>a) {
            swap(a, b);
            sz[b].push_back(a);
            db[b]++;
            szom[a]++, szom[b]++;
        }
    }
    for (long long i=1; i<=n; i++) {
        ans+=db[i]*(szom[i]-db[i]);
    }
    cout << ans << "\n";
    cin >> q;
    for (long long i=1; i<=q; i++) {
        long long x;
        cin >> x;
        for (long long i=0; i<sz[x].size(); i++) {
            long long a=sz[x][i];
            db[a]++;
            sz[a].push_back(x);
            ans+=szom[a]+1;
            ans-=2*db[a];
        }
        ans-=db[x]*(szom[x]-db[x]);
        db[x]=0;
        sz[x].clear();
        cout << ans << "\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
//#define int long long
#define pii pair<ll,ll>
#define F first
#define S second
int const M=3e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;
int inn[M];
set<int>outt[M];
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		inn[b]++;
		outt[a].insert(b);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll tmp=(ll)inn[i];
		ll tmp2=(ll)outt[i].size();
		ans+=(tmp*tmp2);
	}
	int q;
	cin>>q;
	while(q--)
	{
		cout<<ans<<"\n";
		int x;
		cin>>x;
		ll sz1=(ll)outt[x].size();
		ll sz2=(ll)inn[x];
		//cout<<sz1<<" "<<sz2<<"**********"<<endl;
		ans-=sz1*sz2;
		while(outt[x].size())
		{
			int tmp=*outt[x].begin();
			//cout<<ans<<" ";
			//cout<<x<<" "<<tmp<<"***********"<<endl;
			ans-=(ll)outt[tmp].size();
			ans+=(ll)inn[tmp];
			//cout<<(ll)outt[tmp].size()<<" ";
			//cout<<(ll)inn[tmp].size()-1<<" "<<"*********"<<endl;
			ans--;
			outt[x].erase(tmp);
			inn[x]++;
			inn[tmp]--;
			outt[tmp].insert(x);
		}
	}
	cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
//#define int long long
#define pii pair<ll,ll>
#define F first
#define S second
int const M=3e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;
int inn[M];
vector<int>outt[M];
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		inn[b]++;
		outt[a].pb(b);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll tmp=(ll)inn[i];
		ll tmp2=(ll)outt[i].size();
		ans+=(tmp*tmp2);
	}
	int q;
	cin>>q;
	while(q--)
	{
		cout<<ans<<"\n";
		int x;
		cin>>x;
		ll sz1=(ll)outt[x].size();
		ll sz2=(ll)inn[x];
		//cout<<sz1<<" "<<sz2<<"**********"<<endl;
		ans-=sz1*sz2;
		int ind=(int)outt[x].size()-1;
		for(int i=ind;i>=0;i--){
			int tmp=outt[x][i];
			//cout<<ans<<" ";
			//cout<<x<<" "<<tmp<<"***********"<<endl;
			ans-=(ll)outt[tmp].size();
			ans+=(ll)inn[tmp];
			ans--;
			outt[x].pop_back();
			inn[x]++;
			inn[tmp]--;
			outt[tmp].pb(x);
		}
	}
	cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
//#define int long long
#define pii pair<ll,ll>
#define F first
#define S second
int const M=3e5+10,M2=1e6+10,mod=1e9+7,inf=1e9+10;
set<int>inn[M];
set<int>outt[M];
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		inn[b].insert(a);
		outt[a].insert(b);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll tmp=(ll)inn[i].size();
		ll tmp2=(ll)outt[i].size();
		ans+=(tmp*tmp2);
	}
	int q;
	cin>>q;
	while(q--)
	{
		cout<<ans<<"\n";
		int x;
		cin>>x;
		ll sz1=(ll)outt[x].size();
		ll sz2=(ll)inn[x].size();
		//cout<<sz1<<" "<<sz2<<"**********"<<endl;
		ans-=sz1*sz2;
		while(outt[x].size())
		{
			int tmp=*outt[x].begin();
			//cout<<ans<<" ";
			//cout<<x<<" "<<tmp<<"***********"<<endl;
			ans-=(ll)outt[tmp].size();
			ans+=(ll)inn[tmp].size();
			//cout<<(ll)outt[tmp].size()<<" ";
			//cout<<(ll)inn[tmp].size()-1<<" "<<"*********"<<endl;
			ans--;
			outt[x].erase(tmp);
			inn[x].insert(tmp);
			inn[tmp].erase(x);
			outt[tmp].insert(x);
		}
	}
	cout<<ans<<"\n";
}