#include using namespace std; int main() { int N, M; cin >> N >> M; map> Follow; set Private; for (int i = 0; i < M; i++) { int u, v; cin >> u >> v; Follow[u].insert(v); } int Q; cin >> Q; for (int i = 0; i < Q; i++) { int type, a, b; cin >> type >> a >> b; if (type == 1) { if (Follow[a].count(b)) Follow[a].erase(b); else Follow[a].insert(b); } if (type == 2) { if (Private.count(a)) Private.erase(a); else Private.insert(a); } int Ans = N - Private.size() - (Private.count(a) ? 0 : 1); for (int i : Private) if (Follow[a].count(i) && i != a) Ans++; cout << Ans << endl; } }