#include using namespace std; // #include // #include // #include #include // #include // #include using namespace atcoder; // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") typedef long long int ll; typedef unsigned long long ull; typedef long double ld; typedef pair pll; typedef vector vll; typedef vector vvll; typedef vector vvvll; typedef vector vpll; typedef vector vvpll; typedef vector vb; typedef vector vvb; typedef vector vd; typedef vector vvd; typedef priority_queue > pqpll; typedef priority_queue > pqll; struct edge{ ll to, cost; edge(ll e_to,ll e_cost): to(e_to), cost(e_cost){} }; typedef vector> Graph; #define rep(i,a,n) for(ll i = a;i < n;i++) #define rrep(i,a,n) for(ll i = n-1; i >= a;i--) #define LINF (1LL << 60) #define INF (1 << 30) #define fs first #define sc second #define EPS (ld)1e-10 #define ALL(a) a.begin(), a.end() #define tcheck(a) if((clock() - start)/(ld)CLOCKS_PER_SEC >= a) break #define debug(s) cout << #s << endl #define debugval(x) cout << #x" = " << x << endl template ll sz(vector &pos){ return (ll)pos.size(); } template ll sz(priority_queue > &que) {return (ll)que.size(); } template ll sz(priority_queue, greater > &que) {return (ll)que.size(); } ll sz(string &s) {return (ll)s.size(); } template void chmin(T &a, T b) { if(a > b) a = b; } template void chmax(T &a, T b) { if(a < b) a = b; } ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); } ll lcm(ll a,ll b){ return a / gcd(a,b) * b; } // ll dx[4] = {0,-1,0,1},dy[4] = {-1,0,1,0}; ll dx[8] = {0,-1,-1,-1,0,1,1,1},dy[8] = {-1,-1,0,1,1,1,0,-1}; inline bool isinside(ll i,ll n){ return (i < n && i >= 0); } pll op(pll a, pll b){return {a.fs + b.fs, a.sc + b.sc};} pll e(){return {0,0}; } pll mapping(ll f, pll x){ return {x.fs + x.sc*f, x.sc}; } ll composition(ll f,ll g){return f+g;} ll id(){return 0;} int main(){ ll n; cin >> n; vector> memo(n); rep(i,0,n){ cin >> memo[i].fs >> memo[i].sc.fs >> memo[i].sc.sc; memo[i].sc.fs--; } ll q; cin >> q; vector,string>> query(q); rep(i,0,q){ ll op; cin >> op; if(op == 1){ string x; cin >> x; ll t; cin >> t; t--; query[i].fs = array({1,t,-1}); query[i].sc = x; } else if(op == 2){ ll t; cin >> t; t--; query[i].fs = array({2,t,-1}); } else{ string x; cin >> x; ll l,r; cin >> l >> r; l--; query[i].fs = array({3,l,r}); query[i].sc = x; } } map> mp; auto add = [&mp](string x, ll l, ll r){ auto& st = mp[x]; if(st.size() == 0){ st.emplace(LINF,LINF); st.emplace(-LINF,-LINF); } st.emplace(l,r); auto it = st.lower_bound(pll(l,r)); it--; if(it->first <= l && l <= it->second){ l = min(l, it->first), r = max(r, it->second); st.erase(it); } it = st.lower_bound(pll(l,r)); while(1){ if(l <= it->first && it->first <= r){ r = max(r, it->second); it = st.erase(it); } else break; } st.insert(pll(l,r)); }; vll tmemo; rep(i,0,n){ add(memo[i].fs, memo[i].sc.fs, memo[i].sc.sc); tmemo.emplace_back(memo[i].sc.fs); tmemo.emplace_back(memo[i].sc.sc); } rep(i,0,q){ if(query[i].fs[0] == 2) tmemo.emplace_back(query[i].fs[1]); else if(query[i].fs[0] == 3){ tmemo.emplace_back(query[i].fs[1]); tmemo.emplace_back(query[i].fs[2]); } } sort(ALL(tmemo)); tmemo.erase(unique(ALL(tmemo)),tmemo.end()); map zaatu; rep(i,0,sz(tmemo)) zaatu[tmemo[i]] = i; lazy_segtree seg(vector(sz(tmemo)+1,{0,1})); rep(i,0,n) seg.apply(zaatu[memo[i].sc.fs], zaatu[memo[i].sc.sc],1); rep(i,0,q){ if(query[i].fs[0] == 1){ ll t = query[i].fs[1]; auto& st = mp[query[i].sc]; if(st.size() == 0) cout << "No" << endl; else{ auto it = st.lower_bound(pll(t, LINF)); it--; if(it->first <= t && t < it->second) cout << "Yes" << endl; else cout << "No" << endl; } } else if(query[i].fs[0] == 2){ auto [op,t,_] = query[i].fs; cout << seg.get(zaatu[t]).fs << endl; } else if(query[i].fs[0] == 3){ auto [arr,x] = query[i]; auto [op,l,r] = arr; add(x,l,r); seg.apply(zaatu[l],zaatu[r],1); } } }