#include #include #include #include #include int main() { int n; std::cin >> n; std::vector> query; query.reserve(2 * n); for (int i = 0; i < n; i++) { int l, r, a; std::cin >> l >> r >> a; l--; query.emplace_back(l, a); query.emplace_back(r, ~a); } int q; int inf = 1e9 + 1; std::cin >> q; query.reserve(2 * n + q); for (int i = 0; i < q; i++) { int x; std::cin >> x; x--; query.emplace_back(x, inf); } std::sort(query.begin(), query.end()); std::set mex; for (int i = 0; i <= n; i++) { mex.insert(i); } std::vector count(n + 1); for (auto [x, y]: query) { if (y == inf) { std::cout << *mex.begin() << '\n'; } else if (y >= 0) { if (y < n) { count[y]++; if (count[y] == 1) { mex.erase(y); } } } else { y = ~y; if (y < n) { count[y]--; if (count[y] == 0) { mex.insert(y); } } } } }