#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) #include int main() { int n; cin >> n; vector> info(n); rep(i, n) { string x; int l, r; cin >> x >> l >> r; info[i] = { x, l, r + 1 }; } int q; cin >> q; vector> query(q); rep(i, q) { int qtype; cin >> qtype; if (qtype == 1) { string x; int t; cin >> x >> t; query[i] = { qtype, x, t, -1 }; } if (qtype == 2) { int t; cin >> t; query[i] = { qtype, "", t, -1 }; } if (qtype == 3) { string x; int l, r; cin >> x >> l >> r; query[i] = { qtype, x, l, r + 1 }; } } int comp_cnt = 0; { // compress set st; rep(i, n) { auto [_, l, r] = info[i]; st.insert(l), st.insert(r); } rep(i, q) { auto [_, __, l, r] = query[i]; st.insert(l), st.insert(r); } st.erase(-1); map mp; for (int x : st) mp[x] = comp_cnt++; mp[-1] = -1; rep(i, n) { auto&& [_, l, r] = info[i]; l = mp[l], r = mp[r]; } rep(i, q) { auto&& [_, __, l, r] = query[i]; l = mp[l], r = mp[r]; } } map> entered, exited; atcoder::fenwick_tree fw(comp_cnt + 1); rep(i, n) { auto [x, l, r] = info[i]; entered[x].insert(l); exited[x].insert(r); entered[x].insert(2e9); exited[x].insert(2e9); fw.add(l, 1); fw.add(r, -1); } rep(i, q) { int qtype = get<0>(query[i]); if (qtype == 1) { auto [_, x, t, __] = query[i]; int l = *entered[x].upper_bound(t); int r = *exited[x].upper_bound(t); if (r < l) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if (qtype == 2) { auto [_, __, t, ___] = query[i]; cout << fw.sum(0, t + 1) << endl; } if (qtype == 3) { auto [_, x, l, r] = query[i]; entered[x].insert(l); exited[x].insert(r); fw.add(l, 1); fw.add(r, -1); } } return 0; }