import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class mosaic_sm_sort_rand {
    static class Point implements Comparable<Point> {
        int x, y, index;

        Point(int x, int y, int index) {
            this.x = x;
            this.y = y;
            this.index = index;
        }

        @Override
        public int compareTo(Point o) {
            if (x == o.x) {
                return y - o.y;
            }
            return x - o.x;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    ", index=" + index +
                    '}';
        }
    }

    void solve() throws IOException {
        int n = nextInt();
        Point[] p = new Point[n];
        for (int i = 0; i < n; i++) {
            p[i] = new Point(nextInt(), nextInt(), i);
        }
        int m = nextInt();
        Point[] tmp = new Point[n];
        Point[] tmp2 = new Point[n];
        Random random = new Random(1);
        for (int i = 0; i < m; i++) {
            int a = nextInt() - 1;
            int b = nextInt();
            System.arraycopy(p, a, tmp, 0, b - a);
            Arrays.sort(tmp, 0, b - a);
//            System.err.println(Arrays.toString(Arrays.copyOf(tmp, b - a)));
            int it = 0;
            for (int j = 0; j < b - a; j++) {
//                System.err.println(" try " + tmp[j]);
                if (it == 0 || tmp[j].compareTo(tmp2[it - 1]) != 0) {
                    tmp2[it++] = tmp[j];
                }
            }
//            System.err.println(Arrays.toString(Arrays.copyOf(tmp2, it)));
            int ans1 = -1;
            int ans2 = -1;
            for (int cnt = 0; cnt < 100; cnt++) {
                int L = random.nextInt(it);
                int R = random.nextInt(it);
                if (tmp2[L].x != tmp2[R].x && tmp2[L].y != tmp2[R].y) {
                    ans1 = tmp2[L].index;
                    ans2 = tmp2[R].index;
                }
            }
            out.println((ans1 + 1) + " " + (ans2 + 1));
        }
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    void run() throws IOException {
        br = new BufferedReader(new FileReader("mosaic.in"));
        out = new PrintWriter("mosaic.out");
        solve();
        out.close();
    }

    int nextInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        new mosaic_sm_sort_rand().run();
    }
}
