#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } /** * @file unordered_dense.hpp * @brief 高速な unordered コンテナ * @author kwm_t * @see https://github.com/kwm-t/cp-library/blob/main/base/unordered_dense.hpp */ #ifndef KWM_T_BASE_UNORDERED_DENSE_HPP #define KWM_T_BASE_UNORDERED_DENSE_HPP /** * @brief ローカル環境用(MSC)hashmap/hashset */ #ifdef ATCODER #include template using hash_map = ankerl::unordered_dense::map; template using hash_set = ankerl::unordered_dense::set; #else #include #include template using hash_map = std::unordered_map; template using hash_set = std::unordered_set; #endif #endif // KWM_T_BASE_UNORDERED_DENSE_HPP int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; cin >> n >> m; hash_map>mp0, mp1; rep(i, m) { int u, v; cin >> u >> v; u--, v--; mp0[u].insert(v); } hash_setlock; int q; cin >> q; while (q--) { int q, a, b; cin >> q >> a >> b; a--, b--; if (q == 1) { if (mp0[a].count(b)) { mp0[a].erase(b); } else { mp0[a].insert(b); } } else { if (lock.count(a)) { lock.erase(a); } else { lock.insert(a); } } int ans = n - lock.size();//open for (auto e : mp0[a]) { if (lock.count(e))ans++; } if (!lock.count(a))ans--; cout << ans << endl;; } return 0; }