import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); PriorityQueue queries = new PriorityQueue<>(); TreeSet remain = new TreeSet<>(); for (int i = 0; i <= n; i++) { remain.add(i); } for (int i = 0; i < n; i++) { int left = sc.nextInt(); int right = sc.nextInt(); int value = sc.nextInt(); queries.add(new Query(0, left, value)); queries.add(new Query(2, right, value)); } int q = sc.nextInt(); for (int i = 0; i < q; i++) { queries.add(new Query(1, sc.nextInt(), i)); } int[] ans = new int[q]; HashMap counts = new HashMap<>(); while (queries.size() > 0) { Query x = queries.poll(); if (x.type == 0) { if (!counts.containsKey(x.value)) { counts.put(x.value, 1); remain.remove(x.value); } else { counts.put(x.value, counts.get(x.value) + 1); } } else if (x.type == 1) { ans[x.value] = remain.first(); } else { if (counts.get(x.value) == 1) { counts.remove(x.value); remain.add(x.value); } else { counts.put(x.value, counts.get(x.value) - 1); } } } System.out.println(String.join("\n", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new))); } static class Query implements Comparable { int type; int idx; int value; public Query(int type, int idx, int value) { this.type = type; this.idx = idx; this.value = value; } public int compareTo(Query another) { if (idx == another.idx) { return type - another.type; } else { return idx - another.idx; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }