#include using namespace std; int main () { int N; cin >> N; std::vector> A(N); for (auto& [a, b, c] : A) { cin >> a >> b >> c; } int Q; cin >> Q; vector X(Q); for (auto& a : X) { cin >> a; } vector>> Y(Q + 1); for (auto [l, r, a] : A) { int il = lower_bound(X.begin(), X.end(), l) - X.begin(); Y[il].emplace_back(1, a); int ir = upper_bound(X.begin(), X.end(), r) - X.begin(); Y[ir].emplace_back(-1, a); } map mp; set st; for (int i = 0; i < Q; i ++) { for (auto [p, a] : Y[i]) { mp[a] += p; if (mp[a] == 0) { st.erase(a); } else if (p > 0 && mp[a] == 1) { st.insert(a); } } cout << *(st.begin()) << endl; } }