#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template void chmin(T &a,T b){ if(a>b){ a=b; } } template void chmax(T &a,T b){ if(a unordered_map compress(vector x){ vector unique_v=x; int n=x.size(); sort(all(unique_v)); unordered_map mp; unique_v.erase(unique(all(unique_v)),unique_v.end()); for(int i=0;i v,lazy; ll n; segment_tree(ll x){ ll s=1; while(s> n; vector v; unordered_map> mp; vector vl(n),vr(n); rep(i,n){ string x; ll l,r; cin >> x >> l >> r; mp[x].insert({r,l}); v.push_back(l); v.push_back(r); vl[i]=l; vr[i]=r; } for(auto &[k,st]:mp) st.insert({INF,INF}); ll q; cin >> q; vector> que(q); vector str(q); rep(i,q){ ll z; cin >> z; if(z==1){ string x; ll t; cin >> x >> t; str[i]=x; que[i]={1,t}; } if(z==2){ ll t; cin >> t; que[i]={2,t}; v.push_back(t); } if(z==3){ string x; ll l,r; cin >> x >> l >> r; str[i]=x; que[i]={3,l,r}; v.push_back(l); v.push_back(r); } } v.push_back(INF); unordered_map z=compress(v); ll m=z.size(); segment_tree st(m); rep(i,n) st.add(z[vl[i]],z[vr[i]]+1,1); rep(i,q){ if(que[i].front()==1){ string x=str[i]; ll t=que[i][1]; if(!mp.count(x)){ cout << "No\n"; continue; } ll l,r; tie(r,l)=(*mp[x].lower_bound({t,t})); if(l<=t&&t<=r) cout << "Yes\n"; else cout << "No\n"; } if(que[i].front()==2){ ll t=que[i][1]; if(!z.count(t)) assert(0); cout << st.query(z[t],z[t]+1) << '\n'; } if(que[i].front()==3){ string x=str[i]; ll l=que[i][1],r=que[i][2]; mp[x].insert({r,l}); mp[x].insert({INF,INF}); if(!z.count(l)||!z.count(r)) assert(0); st.add(z[l],z[r]+1,1); } } }