#include using namespace std; #include using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int main() { int n; cin >> n; map mp; vector x(n); vector l(n), r(n); rep(i,n){ cin >> x[i] >> l[i] >> r[i]; mp[l[i]] = 0; mp[r[i]] = 0; mp[r[i]+1] = 0; } int q; cin >> q; vector t(q), L(q), R(q), T(q); vector X(q); rep(qi,q){ cin >> t[qi]; if(t[qi]==1){ cin >> X[qi] >> T[qi]; mp[T[qi]] = 0; } else if(t[qi]==2){ cin >> T[qi]; mp[T[qi]] = 0; mp[T[qi]+1] = 0; } else{ cin >> X[qi] >> L[qi] >> R[qi]; mp[L[qi]] = 0; mp[R[qi]] = 0; mp[R[qi]+1] = 0; } } int m = 0; for(auto & p : mp){ p.second = m++; } fenwick_tree bit(m); map>> xs; rep(i,n){ bit.add(mp[l[i]], 1); bit.add(mp[r[i]+1], -1); xs[x[i]].emplace(l[i], r[i]); } rep(qi,q){ if(t[qi]==1){ auto it = xs[X[qi]].upper_bound({T[qi], 1e9}); if(it==xs[X[qi]].end()){ cout << "No" << endl; } else{ it--; auto [a, b] = *it; if(a<=T[qi] && T[qi]<=b){ cout << "Yes" << endl; } else{ cout << "No" << endl; } } } else if(t[qi]==2){ cout << bit.sum(0, mp[T[qi]+1]) << endl; } else{ xs[X[qi]].emplace(L[qi], R[qi]); bit.add(mp[L[qi]],1); bit.add(mp[R[qi]+1],-1); } } return 0; }