#include using namespace std; template struct dual_invertible_binary_indexed_tree{ int N; vector BIT; function f; function inv; T E; dual_invertible_binary_indexed_tree(int N, function f, function inv, T E): N(N), BIT(N + 1, E), f(f), inv(inv), E(E){ } void add(int i, T x){ while (i > 0){ BIT[i] = f(BIT[i], x); i -= i & -i; } } void add(int l, int r, T x){ add(l, inv(x)); add(r, x); } T operator [](int i){ i++; T ans = E; while (i <= N){ ans = f(ans, BIT[i]); i += i & -i; } return ans; } }; int main(){ int N; cin >> N; vector X(N); vector L(N), R(N); for (int i = 0; i < N; i++){ cin >> X[i] >> L[i] >> R[i]; R[i]++; } int Q; cin >> Q; vector T(Q); vector x(Q); vector t(Q), l(Q), r(Q); for (int i = 0; i < Q; i++){ cin >> T[i]; if (T[i] == 1){ cin >> x[i] >> t[i]; } if (T[i] == 2){ cin >> t[i]; } if (T[i] == 3){ cin >> x[i] >> l[i] >> r[i]; r[i]--; } } vector time; for (int i = 0; i < N; i++){ time.push_back(L[i]); time.push_back(R[i]); } for (int i = 0; i < Q; i++){ if (T[i] == 1){ time.push_back(t[i]); } if (T[i] == 2){ time.push_back(t[i]); } if (T[i] == 3){ time.push_back(l[i]); time.push_back(r[i]); } } sort(time.begin(), time.end()); time.erase(unique(time.begin(), time.end()), time.end()); for (int i = 0; i < N; i++){ L[i] = lower_bound(time.begin(), time.end(), L[i]) - time.begin(); R[i] = lower_bound(time.begin(), time.end(), R[i]) - time.begin(); } for (int i = 0; i < Q; i++){ if (T[i] == 1){ t[i] = lower_bound(time.begin(), time.end(), t[i]) - time.begin(); } if (T[i] == 2){ t[i] = lower_bound(time.begin(), time.end(), t[i]) - time.begin(); } if (T[i] == 3){ l[i] = lower_bound(time.begin(), time.end(), l[i]) - time.begin(); r[i] = lower_bound(time.begin(), time.end(), r[i]) - time.begin(); } } int M = time.size(); set id; for (int i = 0; i < N; i++){ id.insert(X[i]); } for (int i = 0; i < Q; i++){ if (t[i] == 1 || t[i] == 3){ id.insert(x[i]); } } map>> st; for (string s : id){ st[s].insert(make_pair(-1, 1)); st[s].insert(make_pair(M + 1, 0)); } dual_invertible_binary_indexed_tree BIT(M, plus(), negate(), 0); for (int i = 0; i < N; i++){ st[X[i]].insert(make_pair(L[i], 0)); st[X[i]].insert(make_pair(R[i], 1)); BIT.add(L[i], R[i], 1); } for (int i = 0; i < Q; i++){ if (T[i] == 1){ auto itr = st[x[i]].upper_bound(make_pair(t[i], 2)); if ((*itr).second == 1){ cout << "Yes" << endl; } else { cout << "No" << endl; } } if (T[i] == 2){ cout << BIT[t[i]] << endl; } if (T[i] == 3){ st[x[i]].insert(make_pair(l[i], 0)); st[x[i]].insert(make_pair(r[i], 1)); BIT.add(l[i], r[i], 1); } } }