#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector> edge(m); vector c; for(auto &&[u, v] : edge){ cin >> u >> v; c.emplace_back(u); c.emplace_back(v); } int Q; cin >> Q; vector> query(Q); for(auto &&[cmd, a, b] : query){ cin >> cmd >> a >> b; c.emplace_back(a); c.emplace_back(b); } // aにフォローされていて非公開のユーザーの数を数える int cur = n; sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); m = c.size(); vector tb(m); vector> S(m); for(auto &&[u, v] : edge){ u = lower_bound(c.begin(), c.end(), u) - c.begin(); v = lower_bound(c.begin(), c.end(), v) - c.begin(); S[u].insert(v); } for(auto &&[cmd, a, b] : query){ a = lower_bound(c.begin(), c.end(), a) - c.begin(); b = lower_bound(c.begin(), c.end(), b) - c.begin(); if(cmd == 1){ if(S[a].count(b)){ S[a].erase(b); }else{ S[a].insert(b); } }else{ if(tb[a]){ tb[a] = false; cur++; }else{ tb[a] = true; cur--; } } int vl = cur - 1 + tb[a]; for(auto u : S[a]) vl += tb[u]; cout << vl << '\n'; } }