#include #include using namespace std; using namespace atcoder; int hsh(string s){ int res = 0; for(auto c : s){ res *= 30; res += c - 'a' + 1; } return res; } int main(){ // input int N; cin >> N; set S; vector X(N); vector H(N),L(N),R(N); map>> M; for(int i = 0; i < N; i++){ cin >> X[i] >> L[i] >> R[i]; S.insert(L[i]); S.insert(R[i]); H[i] = hsh(X[i]); M[H[i]].insert({L[i],R[i]}); } // query int Q; cin >> Q; queue> q; while(Q--){ int op,t,l,r; string x; cin >> op; if(op == 1){ cin >> x >> t; S.insert(t); int h = hsh(x); q.push({h,t}); } else if(op == 2){ cin >> t; q.push({t}); } else if(op == 3){ cin >> x >> l >> r; S.insert(l); S.insert(r); int h = hsh(x); q.push({h,l,r}); } } // za-atu map Z; int siz = 0; for(auto t : S){ Z[t] = siz; siz++; } // segment tree construction fenwick_tree fw(siz+1); for(int i = 0; i < N; i++){ fw.add(Z[L[i]],1); fw.add(Z[R[i]],-1); } // answer queries while(!q.empty()){ vector v = q.front(); q.pop(); if(v.size() == 1) cout << fw.sum(0,Z[v[0]]) << endl; else if(v.size() == 2){ if(!M.count(v[0])) cout << "No" << endl; else{ auto it = M[v[0]].lower_bound({v[1],2e9}); it--; auto p = *it; cout << (p.first <= v[1] && v[1] <= p.second ? "Yes":"No") << endl; } } else if(v.size() == 3){ M[v[0]].insert({v[1],v[2]}); fw.add(Z[v[1]],1); fw.add(Z[v[2]],-1); } } }