import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n= int(input()) lr = [list(map(int,input().split())) for i in range(n)] q = int(input()) x = list(map(int,input().split())) lr.sort(key = lambda x: (x[2], x[0])) lr = lr[::-1] INF= 10**10 seg_len = 1<<19 # > 5*(10**5) seg = [INF]*(2*seg_len) for i in range(q): seg[i+seg_len] = i for i in range(seg_len)[::-1]: seg[i] = min(seg[i*2], seg[i*2+1]) def update(pos): pos += seg_len seg[pos] = INF while True: pos >>= 1 if not pos: break seg[pos] = min(seg[pos<<1], seg[pos<<1|1]) def get_query(l,r): l += seg_len; r += seg_len res = INF while l < r: if l & 1: res = min(res, seg[l]) l += 1 if r & 1: r -= 1 res = min(res, seg[r]) l >>= 1; r >>= 1 return res ans = [-1]*q for num in range(n+10): use = [] mx = 0 while lr and lr[-1][2] == num: l,r,_ = lr.pop() tl = bisect_left(x,l) tr = bisect_right(x,r) mx = max(mx, tr) use.append([tl,tr]) if not use: break ss = set() for i in range(len(use)): tl,tr = use[i] if i == 0: tmp = get_query(0, tl) while tmp != INF: update(tmp) ss.add(tmp) ans[tmp] = num tmp = get_query(0,tl) if i != 0: prer = use[i-1][1] tmp = get_query(prer, tl) while tmp != INF: update(tmp) ss.add(tmp) ans[tmp] = num tmp = get_query(prer,tl) tmp = get_query(mx, seg_len) while tmp != INF: update(tmp) ss.add(tmp) ans[tmp] = num tmp = get_query(mx, seg_len) for i in range(q): if ans[i] == -1: ans[i] = num print(*ans, sep = "\n")