#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; template struct value_compression : vector { bool built = false; using VS = vector; using VS::VS; value_compression(vector v) : vector(move(v)) {} void build() { sort(this->begin(), this->end()); this->erase(unique(this->begin(), this->end()), this->end()); built = true; } template void convert(T first, T last) { assert(built); for (; first != last; ++first) *first = (*this)(*first); } int operator()(S x) { assert(built); return lower_bound(this->begin(), this->end(), x) - this->begin(); } void clear() { this->clear(); built = false; } }; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; value_compression vc; vector

es(m); for (auto& [u, v] : es) { cin >> u >> v; u--, v--; vc.emplace_back(u); vc.emplace_back(v); } int q; cin >> q; vector> qs(q); for (auto& [q, a, b] : qs) { cin >> q >> a >> b; if (q == 1) { a--, b--; vc.emplace_back(a); vc.emplace_back(b); } else { a--; vc.emplace_back(a); } } vc.build(); int sz = vc.size(); VVI to(sz); for (auto [u, v] : es) { to[vc(u)].emplace_back(vc(v)); } vector open(sz, true); for (auto [q, a, b] : qs) { if (q == 1) { a = vc(a), b = vc(b); if (auto it = find(all(to[a]), b); it == to[a].end()) { to[a].emplace_back(b); } else { to[a].erase(it); } } else { a = vc(a); open[a] ^= 1; } int ans = n - sz + accumulate(all(open), 0) - open[a]; for (int b : to[a]) if (!open[b]) ans++; cout << ans << '\n'; } }