#include <bits/stdc++.h> using namespace std; #include <atcoder/all> 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<ll,ll>; using lb = long double; using T = tuple<ll, ll, ll>; #ifdef LOCAL # include <debug_print.hpp> # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast<void>(0)) #endif int main() { int n; cin >> n; map<int, int> mp; vector<string> x(n); vector<int> 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<int> t(q), L(q), R(q), T(q); vector<string> 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; } 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<int> bit(m); map<string, set<pair<int, int>>> 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], -1}); 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; }