#include using namespace std; using ll = long long; struct LazySegmentTree { private: int n; vector node, lazy; public: LazySegmentTree(vector v) { int sz = (int)v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1); lazy.resize(2*n-1, 0); for(int i=0; i=0; i--) node[i] = node[i*2+1] + node[i*2+2]; } void eval(int k, int l, int r) { if(lazy[k] != 0) { node[k] += lazy[k]; if(r - l > 1) { lazy[2*k+1] += lazy[k] / 2; lazy[2*k+2] += lazy[k] / 2; } lazy[k] = 0; } } void add(int a, int b, ll x, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return; if(a <= l && r <= b) { lazy[k] += (r - l) * x; eval(k, l, r); } else { add(a, b, x, 2*k+1, l, (l+r)/2); add(a, b, x, 2*k+2, (l+r)/2, r); node[k] = node[2*k+1] + node[2*k+2]; } } ll getsum(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; eval(k, l, r); if(b <= l || r <= a) return 0; if(a <= l && r <= b) return node[k]; ll vl = getsum(a, b, 2*k+1, l, (l+r)/2); ll vr = getsum(a, b, 2*k+2, (l+r)/2, r); return vl + vr; } }; int main() { int N; cin >> N; vector X(N, ""s); vector L(N, 0), R(N, 0); for(int i = 0; i < N; i++) { cin >> X[i] >> L[i] >> R[i]; } int Q; cin >> Q; vector q(Q, 0), t1(0, 0), t2(0, 0), l3(0, 0), r3(0, 0); vector x1(0, ""s), x3(0, ""s); for(int i = 0; i < Q; i++) { cin >> q[i]; if(q[i] == 1) { string x; int t; cin >> x >> t; x1.push_back(x); t1.push_back(t); } if(q[i] == 2) { int t; cin >> t; t2.push_back(t); } if(q[i] == 3) { string x; int l, r; cin >> x >> l >> r; x3.push_back(x); l3.push_back(l); r3.push_back(r); } } vector P(0, 0); for(int i = 0; i < N; i++) { P.push_back(L[i]); P.push_back(R[i]); } for(int i = 0; i < t1.size(); i++) { P.push_back(t1[i]); } for(int i = 0; i < t2.size(); i++) { P.push_back(t2[i]); } for(int i = 0; i < l3.size(); i++) { P.push_back(l3[i]); P.push_back(r3[i]); } vector PP(P); sort(begin(PP), end(PP)); PP.erase(unique(begin(PP), end(PP)), end(PP)); int NN(PP.size()); for(int i = 0; i < P.size(); i++) { P[i] = lower_bound(begin(PP), end(PP), P[i]) - begin(PP); } for(int i = 0; i < N; i++) { L[i] = P[i*2]; R[i] = P[i*2+1]; } for(int i = 0; i < t1.size(); i++) { t1[i] = P[N*2 + i]; } for(int i = 0; i < t2.size(); i++) { t2[i] = P[N*2 + t1.size() + i]; } for(int i = 0; i < l3.size(); i++) { l3[i] = P[N*2 + t1.size() + t2.size() + i*2]; r3[i] = P[N*2 + t1.size() + t2.size() + i*2+1]; } map>> mp; for(int i = 0; i < N; i++) { mp[X[i]].push_back({L[i], R[i]}); } LazySegmentTree seg( vector(NN, 0) ); for(int i = 0; i < N; i++) { seg.add(L[i], R[i]+1, 1); } int idx1(0), idx2(0), idx3(0); for(int i = 0; i < Q; i++) { if(q[i] == 1) { string ans("No"); vector V(mp[x1[idx1]]); /* cerr << '!'; for(auto [x, y] : V) { cerr << " : "; cerr << x << ' ' << y; } cerr << endl; cerr << "!! " << t1[idx1] << endl; */ if(t1[idx1] < V[0].first) { ans = "No"; }else { int M(V.size()); if(V[M-1].first <= t1[idx1] && t1[idx1] <= V[M-1].second) { ans = "Yes"; }else if(V[M-1].second < t1[idx1]) { ans = "No"; }else { int ok(0), ng(M-1); while(1 < ng-ok) { int mid = (ok+ng)/2; if(V[mid].first <= t1[idx1]) ok = mid; else ng = mid; } /* cout << V[ok].first << ' ' << V[ok].second << endl; */ if(V[ok].first <= t1[idx1] && t1[idx1] <= V[ok].second) { ans = "Yes"; }else { ans = "No"; } } } cout << ans << endl; idx1++; } if(q[i] == 2) { cout << seg.getsum(t2[idx2], t2[idx2]+1) << endl; idx2++; } if(q[i] == 3) { seg.add(l3[idx3], r3[idx3]+1, 1); mp[x3[idx3]].push_back({l3[idx3], r3[idx3]}); idx3++; } } return 0; }