def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 events = [] for _ in range(N): l = int(input[ptr]) r = int(input[ptr+1]) a = int(input[ptr+2]) ptr +=3 events.append((l, 0, a)) events.append((r + 1, 1, a)) # Sort events by pos, then add before remove (type 0 before 1) events.sort(key=lambda x: (x[0], x[1])) Q = int(input[ptr]) ptr +=1 x_list = list(map(int, input[ptr:ptr+Q])) ptr += Q current_mex = 0 count = dict() e_ptr = 0 result = [] for x in x_list: while e_ptr < len(events) and events[e_ptr][0] <= x: pos, typ, a = events[e_ptr] if typ == 0: # Add event if a in count: count[a] += 1 else: count[a] = 1 # Check if current_mex is affected while current_mex in count: current_mex += 1 else: # Remove event if a in count: count[a] -= 1 if count[a] == 0: del count[a] if a < current_mex: current_mex = min(current_mex, a) e_ptr += 1 result.append(current_mex) print('\n'.join(map(str, result))) if __name__ == '__main__': main()