#include #include #include #include using namespace std; #include using namespace atcoder; using ll = long long; using vll = vector; using vvll = vector; using vvvll = vector; #define all(A) A.begin(),A.end() #define rep(i, n) for (ll i = 0; i < (ll) (n); i++) template bool chmax(T& p, T q, bool C = 1) { if (C == 0 && p == q) { return 1; } if (p < q) { p = q; return 1; } else { return 0; } } template bool chmin(T& p, T q, bool C = 1) { if (C == 0 && p == q) { return 1; } if (p > q) { p = q; return 1; } else { return 0; } } ll gcd(ll(a), ll(b)) { if (a == 0)return b; if (b == 0)return a; ll c = a; while (a % b != 0) { c = a % b; a = b; b = c; } return b; } ll sqrtz(ll N) { ll L = 0; ll R = sqrt(N) + 10000; while (abs(R - L) > 1) { ll mid = (R + L) / 2; if (mid * mid <= N)L = mid; else R = mid; } return L; } using mint = modint998244353; /* 区間をsetで管理するテク 区間は半開区間で持たせる[L,R) */ ll cnt=0; vll AN; ll cm = 0; template struct rangeset { set> S; T INF; rangeset() { INF = 2e18;; S.insert({ INF,INF }); S.insert({ -INF,-INF }); } bool iscovered(T L, T R) { //assert(L<=R); auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); auto st = *itr; return (itr->first <= L && R <= itr->second); } bool iscovered(T x) { return iscovered(x, x + 1); } pair covered(T L, T R) { //assert(L<=R); auto itr = S.lower_bound({ L + 1,L + 1 }); itr--; auto st = *itr; if (itr->first <= L && R <= itr->second) { return st; } else { return { INF,INF }; } } pair covered(T x) { return covered(x, x + 1); } T insert(T L, T R) { if (iscovered(L, R))return T(0); auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); T res = T(0); auto st = *itr; if (itr->first <= L && L <= itr->second) { L = st.first; res -= itr->second - itr->first; itr = S.erase(itr); } else itr = next(itr); while (R > itr->second) { res -= itr->second - itr->first; itr = S.erase(itr); } if (itr->first <= R && R <= itr->second) { res -= itr->second - itr->first; R = itr->second; itr = S.erase(itr); } S.insert({ L,R }); res += R - L; return res; } T insert(T x) { return insert(x, x + 1); } T erase(T L, T R) { auto itr = S.lower_bound({ L + 1,L + 1 }); itr = prev(itr); T res = T(0); auto st = *itr; if (itr->first <= L && R <= itr->second) { if (itr->first < L)S.insert({ itr->first,L }); if (R < itr->second)S.insert({ R,itr->second }); for (ll p = L; p < R; p++) { AN[p] = cm; cnt++; } S.erase(itr); return R - L; } if (itr->first <= L && L < itr->second) { res += itr->second - L; if (itr->first < L)S.insert({ itr->first,L }); for (ll p = L; p < itr->second; p++) { AN[p] = cm; cnt++; } itr = S.erase(itr); } else itr = next(itr); while (itr->second <= R) { res += itr->second - itr->first; for (ll p = itr->first; p < itr->second; p++) { AN[p] = cm; cnt++; } itr = S.erase(itr); } if (itr->first < R && R <= itr->second) { res += R - itr->first; if (R < itr->second)S.insert({ R,itr->second }); for (ll p = itr->first; p < R; p++) { AN[p] = cm; cnt++; } S.erase(itr); } return res; } T erase(T x) { return erase(x, x + 1); } }; struct S { ll a; int size; }; struct F { ll a, b; }; S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; } S e() { return S{0, 0}; } S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; } F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; } F id() { return F{1, 0}; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); //rangeset S; map>> P; ll N; cin >> N; map M; rep(i, N) { ll L, R, A; cin >> L >> R >> A; M[L] = M[R] = 1; P[A].push_back({ L,R }); } ll Q; cin >> Q; vll X(Q); rep(i, Q) { ll x; cin >> x; M[x] = 1; X[i] = x; } ll m = 0; for (auto mm : M) { M[mm.first] = m; m++; } rep(i,N){ vector> NP; ll NL=-1; ll NR=-1; for(auto lr:P[i]){ ll L=lr.first; ll R=lr.second; if(NR+1 seg(m); rep(i,m){ seg.set(i,S{N,1}); } for(ll i=N-1;i>=0;i--) { ll LL = 0; cm = i; for (auto lr : P[i]) { ll L = M[lr.first]; ll R = M[lr.second]; seg.apply(LL,L,F{0,i}); //if (LL < L)S.erase(LL, L); LL = R + 1; } seg.apply(LL,m,F{0,i}); //S.erase(LL, m + 1); } rep(q, Q) { cout << seg.get(M[X[q]]).a << endl; } //cout<