#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include using namespace atcoder; int main() { fast_io(); int n; cin >> n; vector X(n); vector L(n), R(n); vector times; for (int i = 0; i < n; i++) { cin >> X[i] >> L[i] >> R[i]; times.push_back(L[i]); times.push_back(R[i]); } int q; cin >> q; vector com(q); vector x(q); vector t(q), l(q), r(q); for (int i = 0; i < q; i++) { cin >> com[i]; if (com[i] == 1) { cin >> x[i] >> t[i]; times.push_back(t[i]); } else if (com[i] == 2) { cin >> t[i]; times.push_back(t[i]); } else { cin >> x[i] >> l[i] >> r[i]; times.push_back(l[i]); times.push_back(r[i]); } } sort(times.begin(), times.end()); times.erase(unique(times.begin(), times.end()), times.end()); int m = times.size(); fenwick_tree fw(m + 1); map>> mp; for (int i = 0; i < n; i++) { L[i] = lower_bound(times.begin(), times.end(), L[i]) - times.begin(); R[i] = lower_bound(times.begin(), times.end(), R[i]) - times.begin(); fw.add(L[i], 1); fw.add(R[i] + 1, -1); mp[X[i]].insert({L[i], R[i]}); } for (int i = 0; i < q; i++) { if (com[i] == 1) { t[i] = lower_bound(times.begin(), times.end(), t[i]) - times.begin(); auto it = mp[x[i]].lower_bound({t[i] + 1, -1}); if (it == mp[x[i]].begin()) { cout << "No\n"; } else { it--; int l = it->first, r = it->second; if (l <= t[i] && t[i] <= r) { cout << "Yes\n"; } else { cout << "No\n"; } } } else if (com[i] == 2) { t[i] = lower_bound(times.begin(), times.end(), t[i]) - times.begin(); cout << fw.sum(0, t[i] + 1) << "\n"; } else { l[i] = lower_bound(times.begin(), times.end(), l[i]) - times.begin(); r[i] = lower_bound(times.begin(), times.end(), r[i]) - times.begin(); fw.add(l[i], 1); fw.add(r[i] + 1, -1); mp[x[i]].insert({l[i], r[i]}); } } }