#include using namespace std; #include using namespace atcoder; using ll = long long; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using VD = vector; using VVD = vector; using VS = vector; using P = pair; using VP = vector

; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define out(x) cout << x << endl #define dout(x) cout << fixed << setprecision(10) << x << endl #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sz(x) (int)(x.size()) #define re0 return 0 #define pcnt __builtin_popcountll template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = 1e9; constexpr ll INF = 1e18; //using mint = modint1000000007; using mint = modint998244353; int di[4] = {1,0,-1,0}; int dj[4] = {0,1,0,-1}; int main(){ ll n; cin >> n; VP events; VL l(n+100001,-1),r(n+100001,-1),t(n+100001,-1),type(n+100001,-1),ans(n+100001,-1); VS x(n+100001); rep(i,n){ cin >> x[i] >> l[i] >> r[i]; events.emplace_back(l[i],i); events.emplace_back(r[i],i+2*inf); } ll q; cin >> q; ll sqq = sqrt(q); for(ll bl = 0;bl <= sqq;bl++){ for(ll i = sqq*bl;i < sqq*(bl+1);i++){ if(i >= q) break; cin >> type[i+n]; if(type[i+n] == 1){ cin >> x[i+n] >> t[i+n]; events.emplace_back(t[i+n],i+n+inf); } if(type[i+n] == 2){ cin >> t[i+n]; events.emplace_back(t[i+n],i+n+inf); } if(type[i+n] == 3){ cin >> x[i+n] >> l[i+n] >> r[i+n]; } } sort(all(events)); set st; ll cnt = 0; for(auto e:events){ auto [time,i] = e; if(time == INF) break; if(i < inf){ //in st.insert(x[i]); cnt++; } else if(i < 2*inf){ //check i -= inf; if(type[i] == 1){ if(st.count(x[i])){ ans[i] = 1; } else { ans[i] = 0; } } else { ans[i] = cnt; } } else { //out i -= 2*inf; st.erase(x[i]); cnt--; } } rep(i,sz(events)){ if(inf <= events[i].second && events[i].second < 2*inf){ events[i].first = INF; } } for(int i = sqq*bl;i < sqq*(bl+1);i++){ if(type[i] == 3) continue; for(int j = sqq*bl;j < i;j++){ if(type[j] != 3) continue; if(l[j] <= t[i] && t[i] <= r[j]){ if(type[i] == 1){ ans[i] = 1; } else if(type[i] == 2){ ans[i]++; } } } } for(int i = sqq*bl;i < sqq*(bl+1);i++){ if(type[i+n] == 3){ events.emplace_back(l[i+n],i+n); events.emplace_back(r[i+n],i+n+2*inf); } } } for(int i = n;i < n+q;i++){ if(type[i] == 1){ if(ans[i] == 1) out("Yes"); else out("No"); } if(type[i] == 2){ out(ans[i]); } } }