#include using namespace std; const int MOD = 998244353, oo = 1e9 + 10, N = 1e7 + 10; int c[N][2], nodes = 1; pair t[N]; pair neutral = {-1, -1}; pair merge(pair A, pair B) { if (A == neutral) { return B; } if (B == neutral) { return A; } if (A.second >= B.first - 1) { return {min(B.first, A.first), max(B.second, A.second)}; } return A; } void push(int pos) { if (c[pos][0] == 0) { c[pos][0] = ++nodes; } if (c[pos][1] == 0) { c[pos][1] = ++nodes; } t[c[pos][0]] = merge(t[c[pos][0]], t[pos]); t[c[pos][1]] = merge(t[c[pos][1]], t[pos]); t[pos] = neutral; } void update(int l, int r, int L, int R, int v, int pos) { if (l > R || L > r) { return; } if (L <= l && R >= r) { t[pos] = merge(t[pos], {v, v}); return; } if (l < r) { int m = l + r >> 1; push(pos); update(l, m, L, R, v, c[pos][0]); update(m + 1, r, L, R, v, c[pos][1]); } } void update(int l, int r, int v) { update(1, oo - 1, l, r, v, 1); } int get(int l, int r, int x, int pos) { if (l > x || r < x) { return 0; } if (l == r) { if (t[pos].first <= 0) { return t[pos].second + 1; } return 0; } push(pos); int m = l + r >> 1; return get(l, m, x, c[pos][0]) + get(m + 1, r, x, c[pos][1]); } int get(int pos) { return get(1, oo - 1, pos, 1); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < N; ++i) { t[i] = neutral; } vector>> queries(N); for (int i = 0; i < n; ++i) { int l, r, x; cin >> l >> r >> x; if (x < N) { queries[x].push_back({l, r}); } } for (int i = 0; i < N; ++i) { for (auto [l, r] : queries[i]) { update(l, r, i); } } int q; cin >> q; for (int _ = 0; _ < q; ++_) { int x; cin >> x; cout << get(x) << '\n'; } }