#include using namespace std; int main() { int n; cin >> n; vector> event; for (int i = 0; i < n; i++) { int l, r, a; cin >> l >> r >> a; event.push_back({l, 1, a}); event.push_back({r, 3, a}); } int q; cin >> q; for (int i = 0; i < q; i++) { int x; cin >> x; event.push_back({x, 2, i}); } sort(begin(event), end(event)); set unused; for (int i = 0; i <= q; i++) unused.insert(i); vector cnt(q), ans(q); for (auto [x, type, num] : event) { if (type == 1) { // 追加 if (num >= q) continue; if (cnt[num] == 0) unused.erase(num); cnt[num]++; } else if (type == 2) { // クエリ ans[num] = *unused.begin(); } else { // 削除 if (num >= q) continue; cnt[num]--; if (cnt[num] == 0) unused.insert(num); } } for (auto a : ans) cout << a << "\n"; }