import sys readline = sys.stdin.readline from heapq import * from collections import * class QuasiBinaryTree: def __init__(self, rule="min"): if rule == "max": self.pm = -1 else: self.pm = 1 self.inf = 10**18 self.P = [self.inf] self.Q = [] def insert(self, x): heappush(self.P, x * self.pm) def erase(self, x): heappush(self.Q, x * self.pm) def top(self): while self.Q and (self.P[0] == self.Q[0]): heappop(self.P) heappop(self.Q) return self.P[0] * self.pm def f(r, a): return r * M + a N = int(readline()) M = 10 ** 9 + 7 lst = [] for i in range(N): L, R, A = map(int, readline().split()) lst.append((L, R, A)) lst.sort(reverse=True) Q = int(readline()) X = list(map(int, readline().split())) H = [] S = QuasiBinaryTree("min") for i in range(101010): S.insert(i) cnt = defaultdict(int) for x in X: while lst: L, R, A = lst[-1] if A >= 100010: lst.pop() continue if L <= x: heappush(H, (R, A)) cnt[A] += 1 if cnt[A] == 1: S.erase(A) lst.pop() else: break while H: R, A = H[0] if R < x: cnt[A] -= 1 if cnt[A] == 0: S.insert(A) heappop(H) else: break print(S.top())