#BIT plus ver class BITplus: def __init__(self,N): self.N = N self.bit = [0] * (self.N+1) def add(self,i,x): while i <= self.N: self.bit[i] += x i += i & -i def fold(self,i): ans = 0 while i > 0: ans += self.bit[i] i -= i & -i return ans def lb(self,w): if w <= 0:return 0 x = 0 k = 1 while k <= self.N: k <<= 1 k >>= 1 while k: if x + k <= self.N and self.bit[x+k] < w: w -= self.bit[x+k] x += k k >>= 1 return x + 1 #サイズ N の配列をいれる """ def build(self,seq): bit = self.bit N = self.N for i in range(N): bit[i+1] = seq[i] for i in range(1,N+1): if i + (i & -1) <= N: bit[i + (i & -i)] += bit[i] """ N = int(input()) query = [] for _ in range(N): l,r,a = map(int,input().split()) query.append((l,a)) query.append((r + 1,~a)) query.sort(reverse = True) Q = int(input()) X = list(map(int,input().split())) C = 10 ** 5 bit = BITplus(C + 1) from collections import defaultdict d = defaultdict(int) def calc(): if 0 not in d or d[0] == 0: return 0 end = C + 1 start = 0 while end - start > 1: mid = end + start >> 1 u = bit.fold(mid + 1) if u <= mid: end = mid else: start = mid return start + 1 for x in X: while query and query[-1][0] <= x: k,a = query.pop() if a < 0: a = ~a if a > C:continue d[a] -= 1 if d[a] == 0: bit.add(a + 1,-1) else: if a > C:continue d[a] += 1 if d[a] == 1: bit.add(a + 1,1) print(calc())