import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int a = sc.nextInt(); TreeMap> places = new TreeMap<>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (!places.containsKey(x)) { places.put(x, new ArrayList<>()); } places.get(x).add(i); } int t = sc.nextInt(); int[] lefts = new int[t]; int[] rights = new int[t]; for (int i = 0; i < t; i++) { lefts[i] = sc.nextInt(); rights[i] = sc.nextInt(); } int[] ans = new int[n]; Arrays.fill(ans, -1); for (int i = t - 1; i >= 0; i--) { Integer key = lefts[i] - 1; while ((key = places.higherKey(key)) != null) { if (key > rights[i]) { break; } for (int x : places.get(key)) { ans[x] = i + 1; } places.remove(key); } } System.out.println(Arrays.stream(ans).mapToObj(String::valueOf).collect(Collectors.joining("\n"))); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }