#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; priority_queue, vector>, greater>> PQ; for(int i=0; i> l >> r >> a; l--; r--; PQ.push({l, 0, a}); PQ.push({r, 2, a}); } int q; cin >> q; for(int i=0; i> x; x--; PQ.push({x, 1, i}); } vector ans(q); vector cnt(n, 0); set st; for(int i=0; i(PQ.top()); if(t==0){ int a = get<2>(PQ.top()); if(a(PQ.top()); if((int)st.size()==0) ans[idx]=n; else ans[idx]=*st.begin(); }else{ int a = get<2>(PQ.top()); if(a