public class C {
    public static void main(String[] args)throws Exception {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);

        int n = in.nextInt();

        HashSet<Integer> set = new HashSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        for (int i = 0; i < n; i++) {
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(set.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    }
                } else {
                    set.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
        }

        int prevNum = 0;

        Integer[] arr = new Integer[set.size()];
        arr = set.toArray(arr);
        Arrays.sort(arr);

        for (Integer num: arr){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    System.out.println(ansJ+" "+ansI);
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }

}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        TreeSet<Integer> treeSet = new TreeSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        boolean solved = false;

        for (int i = 0; i < n; i++) {
            if(!solved){
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(treeSet.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        System.out.println(ansI+" "+ansJ);
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        System.out.println(ansI+" "+ansJ);
                        return;
                    }
                } else {
                    treeSet.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
            }
        }

        int prevNum = 0;

        for (Integer num: treeSet){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    System.out.println(ansI+" "+ansJ);
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }
}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        List<Data> data = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            data.add(new Data(in.nextInt(),in.nextInt(),i+1));
        }

        data.sort(new Comparator<Data>() {
            @Override
            public int compare(Data o1, Data o2) {
                if(o1.begin.compareTo(o2.begin) == 0){
                    return o2.end.compareTo(o1.end);
                } else {
                    return o1.begin.compareTo(o2.begin);
                }
            }
        });

        Data[] d = new Data[n];
        d = data.toArray(d);

        for (int i = 0; i < n; i++) {
            for (int j = i; d[i].end >= d[j].begin&& j<n; j++) {
                if(d[i].begin<=d[j].begin && d[i].end>=d[j].end && i!=j){
                    System.out.println(d[j].index+" "+d[i].index);
                    return;
                }
                try {
                    Data k = d[j+1];
                } catch (ArrayIndexOutOfBoundsException e){
                    break;
                }
            }
        }

        for (Data data1 : d){
            System.out.println(data1.begin+" "+data1.end+" "+data1.index);
        }

        System.out.println("-1 -1");
    }

    private static class Data implements Comparable<Data>{
        public Integer begin;
        public Integer end;
        public int index;

        public Data(int begin, int end, int index) {
            this.begin = begin;
            this.end = end;
            this.index = index;
        }

        @Override
        public int compareTo(Data o) {
            return this.begin.compareTo(o.begin);
        }

        @Override
        public String toString() {
            return this.begin+" "+this.end+" "+this.index;
        }
    }
}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        List<Data> data = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            data.add(new Data(in.nextInt(),in.nextInt(),i+1));
        }

        data.sort(new Comparator<Data>() {
            @Override
            public int compare(Data o1, Data o2) {
                if(o1.begin.compareTo(o2.begin) == 0){
                    return o1.end.compareTo(o2.end);
                } else {
                    return o1.begin.compareTo(o2.begin);
                }
            }
        });

        Data[] d = new Data[n];
        d = data.toArray(d);

        for (int i = 0; i < n; i++) {
            for (int j = i; d[i].end >= d[j].begin&& j<n; j++) {
                if(d[i].begin<=d[j].begin && d[i].end>=d[j].end && i!=j){
                    System.out.println(d[i].index+" "+d[j].index);
                    return;
                }
                try {
                    Data k = d[j+1];
                } catch (ArrayIndexOutOfBoundsException e){
                    break;
                }
            }
        }

        System.out.println("-1 -1");
    }

    private static class Data implements Comparable<Data>{
        public Integer begin;
        public Integer end;
        public int index;

        public Data(int begin, int end, int index) {
            this.begin = begin;
            this.end = end;
            this.index = index;
        }

        @Override
        public int compareTo(Data o) {
            return this.begin.compareTo(o.begin);
        }

        @Override
        public String toString() {
            return this.begin+" "+this.end+" "+this.index;
        }
    }
}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        Set<Integer> set = new HashSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        for (int i = 0; i < n; i++) {
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(set.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    }
                } else {
                    set.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
        }

        int prevNum = 0;

        int[] arr = new int[set.size()];
        Arrays.sort(arr);

        for (Integer num: arr){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    System.out.println(ansJ+" "+ansI);
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }
}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        List<Data> data = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            data.add(new Data(in.nextInt(),in.nextInt(),i+1));
        }

        data.sort(new Comparator<Data>() {
            @Override
            public int compare(Data o1, Data o2) {
                if(o1.begin.compareTo(o2.begin) == 0){
                    return o1.end.compareTo(o2.end);
                } else {
                    return o1.begin.compareTo(o2.begin);
                }
            }
        });

        Data[] d = new Data[n];
        d = data.toArray(d);

        for (int i = 0; i < n; i++) {
            for (int j = i; (d[i].end >= d[j].begin || d[i].begin == d[j].begin)&& j<n; j++) {
                if(d[i].begin == d[j].begin && i != j){
                    if(d[i].end > d[j].end){
                        System.out.println(d[i].index+" "+d[j].index);
                        return;
                    } else {
                        System.out.println(d[j].index+" "+d[i].index);
                        return;
                    }
                } else
                if(d[i].begin<=d[j].begin && d[i].end>=d[j].end && i!=j){
                    System.out.println(d[j].index+" "+d[i].index);
                    return;
                }
                try {
                    Data k = d[j+1];
                } catch (ArrayIndexOutOfBoundsException e){
                    break;
                }
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data implements Comparable<Data>{
        public Integer begin;
        public Integer end;
        public int index;

        public Data(int begin, int end, int index) {
            this.begin = begin;
            this.end = end;
            this.index = index;
        }

        @Override
        public int compareTo(Data o) {
            return this.begin.compareTo(o.begin);
        }

        @Override
        public String toString() {
            return this.begin+" "+this.end+" "+this.index;
        }
    }
}


import java.io.*;
import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);

        int n = in.nextInt();

        HashSet<Integer> set = new HashSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        for (int i = 0; i < n; i++) {
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(set.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    }
                } else {
                    set.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
        }

        int prevNum = 0;

        Integer[] arr = new Integer[set.size()];
        arr = set.toArray(arr);
        Arrays.sort(arr);

        for (Integer num: arr){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    System.out.println(ansJ+" "+ansI);
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }

}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        List<Data> data = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            data.add(new Data(in.nextInt(),in.nextInt(),i+1));
        }

        data.sort(new Comparator<Data>() {
            @Override
            public int compare(Data o1, Data o2) {
                if(o1.begin.compareTo(o2.begin) == 0){
                    return o1.end.compareTo(o2.end);
                } else {
                    return o1.begin.compareTo(o2.begin);
                }
            }
        });

        Data[] d = new Data[n];
        d = data.toArray(d);

        for (int i = 0; i < n; i++) {
            for (int j = i; (d[i].end >= d[j].begin || d[i].begin == d[j].begin)&& j<n; j++) {
                if(d[i].begin == d[j].begin && i != j){
                    if(d[i].end > d[j].end){
                        System.out.println(d[j].index+" "+d[i].index);
                        return;
                    } else {
                        System.out.println(d[i].index+" "+d[j].index);
                        return;
                    }
                } else
                if(d[i].begin<=d[j].begin && d[i].end>=d[j].end && i!=j){
                    System.out.println(d[j].index+" "+d[i].index);
                    return;
                }
                try {
                    Data k = d[j+1];
                } catch (ArrayIndexOutOfBoundsException e){
                    break;
                }
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data implements Comparable<Data>{
        public Integer begin;
        public Integer end;
        public int index;

        public Data(int begin, int end, int index) {
            this.begin = begin;
            this.end = end;
            this.index = index;
        }

        @Override
        public int compareTo(Data o) {
            return this.begin.compareTo(o.begin);
        }

        @Override
        public String toString() {
            return this.begin+" "+this.end+" "+this.index;
        }
    }
}


import java.io.*;
import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);

        int n = in.nextInt();

        HashSet<Integer> set = new HashSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        for (int i = 0; i < n; i++) {
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(set.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        out.printLine(ansJ+" "+ansI);
                        out.flush();
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        out.printLine(ansJ+" "+ansI);
                        out.flush();
                        return;
                    }
                } else {
                    set.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
        }

        int prevNum = 0;

        Integer[] arr = new Integer[set.size()];
        arr = set.toArray(arr);
        Arrays.sort(arr);

        for (Integer num: arr){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    out.printLine(ansJ+" "+ansI);
                    out.flush();
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        out.printLine("-1 -1");
        out.flush();
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }

}


import java.util.*;

public class C {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        HashSet<Integer> set = new HashSet<>();

        HashMap<Integer,Data> dataMap = new HashMap<>();

        int ansI,ansJ;
        for (int i = 0; i < n; i++) {
                int ai = in.nextInt();
                int aj = in.nextInt();

                if(set.contains(ai)){
                    if(dataMap.get(ai).end > aj){
                        ansI = dataMap.get(ai).index;
                        ansJ = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    } else {
                        ansJ = dataMap.get(ai).index;
                        ansI = i+1;
                        System.out.println(ansJ+" "+ansI);
                        return;
                    }
                } else {
                    set.add(ai);
                    Data data = new Data();
                    data.begin = ai;
                    data.end = aj;
                    data.index = i+1;
                    dataMap.put(ai,data);
                }
        }

        int prevNum = 0;

        Integer[] arr = new Integer[set.size()];
        arr = set.toArray(arr);
        Arrays.sort(arr);

        for (Integer num: arr){
            if(prevNum!=0){
                if(dataMap.get(num).end<= dataMap.get(prevNum).end){
                    ansI = dataMap.get(prevNum).index;
                    ansJ = dataMap.get(num).index;
                    System.out.println(ansJ+" "+ansI);
                    return;
                } else {
                    prevNum = num;
                }
            } else {
                prevNum = num;
            }
        }
        System.out.println("-1 -1");
    }

    private static class Data {
        public int begin;
        public int end;
        public int index;
    }
}


import java.util.*;
import java.io.*;
public class codeforces {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class p implements Comparable<p>{
        int l,r,i;
        p(int l,int r,int i){ this.l=l;this.r=r;this.i=i; }
        @Override
        public int compareTo(p a){return this.l!=a.l ? this.l-a.l : a.r-this.r;}
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);PrintWriter pw = new PrintWriter(System.out);
        int n=sc.nextInt();p[] arr= new p[n];for (int i=0;i<n;i++) arr[i] = new p(sc.nextInt(), sc.nextInt(), i + 1);Arrays.sort(arr);
        for (int i=1;i<n;i++) if (arr[i - 1].r >= arr[i].r) { System.out.println(arr[i].i + " " + arr[i - 1].i);return; }
        System.out.println("-1 -1");
    }
}


import java.util.*;
import java.io.*;
public class codeforces {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class p{
        int l,r;
        p(int l,int r){
            this.l=l;this.r=r;
        }
    }
    static int comp(p a,p b) {
        if (a.l <= b.l && b.r <= a.r) return 2;
        else if (b.l <= a.l && a.r <= b.r) return 1;
        else return 0;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);PrintWriter pw = new PrintWriter(System.out);
        int n=sc.nextInt();p[] arr= new p[n];
        for (int i=0;i<n;i++){
            arr[i]=new p(sc.nextInt(),sc.nextInt());
            for (int j=i-1;j>=0;j--){
                int k=comp(arr[i],arr[j]);
                if (k==1) {System.out.println((i+1) + " " + (j+1));return;}
                else if (k==2) {System.out.println((j+1) + " " + (i+1));return;}
            }
        }
        System.out.println("-1 -1");
    }
}


import java.util.*;
import java.io.*;
public class codeforces {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class p implements Comparable{
        int l,r,i;
        p(int l,int r,int i){ this.l=l;this.r=r;this.i=i; }
        @Override
        public int compareTo(Object o) {
            p a = (p)o;
            return this.l!=a.l ? this.l-l:r-this.r;
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);PrintWriter pw = new PrintWriter(System.out);
        int n=sc.nextInt();p[] arr= new p[n];for (int i=0;i<n;i++) arr[i] = new p(sc.nextInt(), sc.nextInt(), i + 1);Arrays.sort(arr);
        for (int i=1;i<n;i++) if (arr[i - 1].r >= arr[i].r) { System.out.println(arr[i].i + " " + arr[i - 1].i);return; }
        System.out.println("-1 -1");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C {

	public static void main(String[] args){
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		Seg[] a = new Seg[n];
		for(int i = 0; i < n; i++) a[i] = new Seg(i+1, scan.nextInt(), scan.nextInt());
		Arrays.sort(a);
		int resi = -1, resj = -1;
		for(int i = 0; i < n-1; i++) {
			if(a[i+1].l >= a[i].l && a[i+1].r <= a[i].r){
				resi = a[i+1].i;
				resj = a[i].i;
				break;
			}
		}
		out.println(resi+" "+resj);
		out.close();
	}

	static class Seg implements Comparable<Seg> {
		int i, l, r;
		public Seg(int a, int b, int c) {
			i = a;
			l = b;
			r = c;
		}
		public int compareTo(Seg o) {
			if(l != o.l) return l-o.l;
			return o.r-r;
		}
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

		public int nextInt() {return Integer.parseInt(next());}

		public long nextLong() {return Long.parseLong(next());}

		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}

		public double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}

		public char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemCNestedSegments solver = new ProblemCNestedSegments();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemCNestedSegments {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Segment[] segs = new Segment[n];
            for (int i = 0; i < n; ++i) {
                segs[i] = new Segment(in.nextInt(), in.nextInt(), i + 1);
            }
            Arrays.sort(segs);
            for (int i = 1; i < n; ++i) {
                if (segs[i].r <= segs[i - 1].r) {
                    out.println(segs[i].ind + " " + segs[i - 1].ind);
                    return;
                }
            }
            out.println(-1 + " " + -1);
        }

        class Segment implements Comparable<Segment> {
            int l;
            int r;
            int ind;

            Segment(int a, int b, int i) {
                l = a;
                r = b;
                ind = i;
            }

            public int compareTo(Segment o) {
                if (l == o.l) return o.r - r;
                return l - o.l;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.*;

public class C {

	/*
	 * 6
1 1
2 2
3 3
4 4
114214 125125
19360 19365

6
1 1
2 2
3 3
4 4
114214
125125
19395 19360
	 */

	static range ar[];
	public static void main(String args[]) {
		JS in = new JS();
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		ar = new range[N];
		for(int i = 0; i < N; i++) {
			ar[i] = new range(in.nextInt(), in.nextInt(), i+1);
		}
		Arrays.sort(ar);

		int ys[] = new int[N];
		for(int i = 0; i < N; i++) ys[i] = ar[i].r;
		RMQ rmq = new RMQ(ys);

		for(int i = 0; i < N-1; i++) {
			if(ar[i+1].l > ar[i].r) continue;
			int last = bs(i+1, N-1, ar[i].r);
			if(rmq.query(i+1, last) <= ar[i].r) {
				//possible, get answer and return;

				for(int j = i+1; j <= last; j++) {
					if(ar[j].r <= ar[i].r) {
						System.out.println(ar[j].id+" "+ar[i].id);
						return;
					}
				}

			}

		}
		System.out.println("-1 -1");

		out.close();
	}

	static int bs(int lo, int hi, int max) {
		if(lo==hi) return lo;
		if(lo+1 == hi) {
			if(ar[hi].l <= max) return hi;
			return lo;
		}
		int mid = (lo+hi)/2;
		if(ar[mid].l <= max) return bs(mid, hi, max);
		return bs(lo, mid, max);

	}

	static class range implements Comparable<range>{
		int l, r, id;
		public range(int a, int b, int c) {
			l=a;
			r=b;
			id = c;
		}
		@Override
		public int compareTo(range o) {
			if(this.l == o.l) return o.r-this.r;
			return this.l-o.l;
		}
	}

	static class RMQ {
		int[] vs;
		int[][] lift;

		public RMQ(int[] vs) {
			this.vs = vs;
			int n = vs.length;
			int maxlog = Integer.numberOfTrailingZeros(Integer.highestOneBit(n)) + 2;
			lift = new int[maxlog][n];
			for (int i = 0; i < n; i++)
				lift[0][i] = vs[i];
			int lastRange = 1;
			for (int lg = 1; lg < maxlog; lg++) {
				for (int i = 0; i < n; i++) {
					lift[lg][i] = Math.min(lift[lg - 1][i], lift[lg - 1][Math.min(i + lastRange, n - 1)]);
				}
				lastRange *= 2;
			}
		}

		public int query(int low, int hi) {
			int range = hi - low + 1;
			int exp = Integer.highestOneBit(range);
			int lg = Integer.numberOfTrailingZeros(exp);
			return Math.min(lift[lg][low], lift[lg][hi - exp + 1]);
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}


import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Problem976C {

	private static Map<Segment, Integer> indexes = new HashMap<>();
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Segment> arr = new ArrayList<>();
		for(int i = 0; i < n; i++)
		{
			Segment s = new Segment(in.nextInt(), in.nextInt());
			arr.add(s);
			indexes.put(s, i + 1);
		}
		in.close();

		arr.sort(new Comparator<Segment>() {
			@Override
			public int compare(Segment o1, Segment o2) {
				return o1.left != o2.left ? Integer.compare(o1.left, o2.left)
						: Integer.compare(o2.right, o1.right);
			}
		});

		System.out.println(getInterPosition(arr));
	}

	private static String getInterPosition(List<Segment> arr)
	{
		int maxRight = Integer.MIN_VALUE;
		int maxIdx = 0;

		for(Segment seg : arr)
		{
			if(seg.left >= maxRight || seg.right > maxRight)
			{
				maxRight = seg.right;
				maxIdx = indexes.get(seg);
			}
			else
			{
				return indexes.get(seg) + " " + maxIdx;
			}
		}

		return "-1 -1";
	}

	private static class Segment
	{
		int right, left;

		public Segment(int left, int right) {
			this.right = right;
			this.left = left;
		}
	}
}


import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Problem976C {

	private static Map<Segment, Integer> indexes = new HashMap<>();
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Segment> arr = new ArrayList<>();
		for(int i = 0; i < n; i++)
		{
			Segment s = new Segment(in.nextInt(), in.nextInt());
			arr.add(s);
			indexes.put(s, i + 1);
		}
		in.close();

		arr.sort(new Comparator<Segment>() {
			@Override
			public int compare(Segment o1, Segment o2) {
				return Integer.compare(o1.left, o2.left);
			}
		});

		System.out.println(getInterPosition(arr));
	}

	private static String getInterPosition(List<Segment> arr)
	{
		int idxFirst = 0;
		int idxSecond = 1;

		while(idxFirst < arr.size() && idxSecond < arr.size())
		{
			Segment s1 = arr.get(idxFirst);
			Segment s2 = null;
			do
			{
				s2 = arr.get(idxSecond);
				if(isIntersect(s1, s2))
				{
					return indexes.get(s2) + " " + indexes.get(s1);
				}
				idxSecond++;
			}while(idxSecond < arr.size() && s2.left <= s1.right);
			idxFirst++;
			idxSecond = idxFirst + 1;
		}
		return "-1 -1";
	}

	private static boolean isIntersect(Segment s1, Segment s2)
	{
		return s2.left >= s1.left && s2.right <= s1.right;
	}

	private static class Segment
	{
		int right, left;

		public Segment(int left, int right) {
			this.right = right;
			this.left = left;
		}
	}
}


import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Problem976C {

	private static Map<Segment, Integer> indexes = new HashMap<>();
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Segment> arr = new ArrayList<>();
		for(int i = 0; i < n; i++)
		{
			Segment s = new Segment(in.nextInt(), in.nextInt());
			arr.add(s);
			indexes.put(s, i + 1);
		}
		in.close();

		arr.sort(new Comparator<Segment>() {
			@Override
			public int compare(Segment o1, Segment o2) {
				return o1.left != o2.left ? Integer.compare(o1.left, o2.left)
						: Integer.compare(o2.right, o1.right);
			}
		});

		System.out.println(getInterPosition(arr));
	}

	private static String getInterPosition(List<Segment> arr)
	{
		int maxRight = Integer.MIN_VALUE;
		int maxIdx = 0;

		for(Segment seg : arr)
		{
			if(seg.left > maxRight || seg.right > maxRight)
			{
				maxRight = seg.right;
				maxIdx = indexes.get(seg);
			}
			else
			{
				return indexes.get(seg) + " " + maxIdx;
			}
		}

		return "-1 -1";
	}

	private static class Segment
	{
		int right, left;

		public Segment(int left, int right) {
			this.right = right;
			this.left = left;
		}
	}
}


import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Problem976C {

	private static Map<Segment, Integer> indexes = new HashMap<>();
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Segment> arr = new ArrayList<>();
		for(int i = 0; i < n; i++)
		{
			Segment s = new Segment(in.nextInt(), in.nextInt());
			arr.add(s);
			indexes.put(s, i + 1);
		}
		in.close();

		arr.sort(new Comparator<Segment>() {
			@Override
			public int compare(Segment o1, Segment o2) {
				return Integer.compare(o1.left, o2.left);
			}
		});

		System.out.println(getInterPosition(arr));
	}

	private static String getInterPosition(List<Segment> arr)
	{
		int maxRight = Integer.MIN_VALUE;
		int maxIdx = 0;

		for(Segment seg : arr)
		{
			if(seg.left >= maxRight || seg.right > maxRight)
			{
				maxRight = seg.right;
				maxIdx = indexes.get(seg);
			}
			else
			{
				return indexes.get(seg) + " " + maxIdx;
			}
		}

		return "-1 -1";
	}

	private static class Segment
	{
		int right, left;

		public Segment(int left, int right) {
			this.right = right;
			this.left = left;
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class newthignss {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		Pair lines[]=new Pair[n];

		for(int i=0;i<n;i++)
		{
			lines[i]=new Pair(scan.nextInt(),scan.nextInt(),i+1);

		}
		Arrays.sort(lines,new compare());
//		//for(int i=0;i<n;i++)
//		{
//			System.out.println(lines[i].a+" "+lines[i].b);
//		}
		int max=0;
		for(int i=1;i<n;i++)
		{
			if(lines[max].b>=lines[i].b){
				System.out.println(lines[i].index+" "+lines[max].index);
				return;
			}else{
				max=i;

			}

		}
		System.out.println(-1+" "+-1);
	}
}
class Pair{
	int a;
	int b;
	int index;
	Pair(int x,int y,int z)
	{
		a=x;
		b=y;
		index=z;
	}

}
class compare implements Comparator<Pair>
{

	@Override
	public int compare(Pair a, Pair b) {
		if(a.a!=b.b){
		if(a.a>b.a)
		{
			return 1;
		}else if(a.a<b.a)
		{
			return -1;
		}else{
			return 0;
		}}else{
			if(a.b>b.b){
				return 1;
			}else if(b.b<a.b)
			{
				return -1;
			}else{
				return 0;

			}
		}
	}

}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class newthignss {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		Pair lines[]=new Pair[n];

		for(int i=0;i<n;i++)
		{
			lines[i]=new Pair(scan.nextInt(),scan.nextInt(),i+1);

		}
		Arrays.sort(lines,new compare());
//		//for(int i=0;i<n;i++)
//		{
//			System.out.println(lines[i].a+" "+lines[i].b);
//		}
		int max=0;
		for(int i=1;i<n;i++)
		{
			if(lines[max].b>=lines[i].b){
				System.out.println(lines[i].index+" "+lines[max].index);
				return;
			}else{
				max=i;

			}

		}
		System.out.println(-1+" "+-1);
	}
}
class Pair{
	int a;
	int b;
	int index;
	Pair(int x,int y,int z)
	{
		a=x;
		b=y;
		index=z;
	}

}
class compare implements Comparator<Pair>
{

	@Override
	public int compare(Pair a, Pair b) {
		if(a.a!=b.a){
		if(a.a>b.a)
		{
			return 1;
		}else if(a.a<b.a)
		{
			return -1;
		}else{
			return 0;
		}}else{
			if(a.b<b.b){
				return 1;
			}else if(b.b<a.b)
			{
				return -1;
			}else{
				return 0;

			}
		}
	}

}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class newthignss {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		Pair lines[]=new Pair[n];

		for(int i=0;i<n;i++)
		{
			lines[i]=new Pair(scan.nextInt(),scan.nextInt(),i+1);

		}
		Arrays.sort(lines,new compare());
//		//for(int i=0;i<n;i++)
//		{
//			System.out.println(lines[i].a+" "+lines[i].b);
//		}
		int max=0;
		for(int i=1;i<n;i++)
		{
			if(lines[max].b>=lines[i].b){
				System.out.println(lines[i].index+" "+lines[max].index);
				return;
			}else{
				max=i;

			}

		}
		System.out.println(-1+" "+-1);
	}
}
class Pair{
	int a;
	int b;
	int index;
	Pair(int x,int y,int z)
	{
		a=x;
		b=y;
		index=z;
	}

}
class compare implements Comparator<Pair>
{

	@Override
	public int compare(Pair a, Pair b) {
		if(a.a>b.a)
		{
			return 1;
		}else if(a.a<b.a)
		{
			return -1;
		}else{
			return 0;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.util.Arrays.sort;

public class C_Nested_Segments {
    static class pair{
        int l,r,idx;
        public pair(int l,int r,int idx){
            this.l = l;
            this.r = r;
            this.idx = idx;
        }
    }
    static int n;
    static pair ar[];
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk;
        n = parseInt(in.readLine());
        ar = new pair[n + 1];
        ar[0] = new pair(0,0,0);
        for (int i = 1; i <= n; i++) {
            tk = new StringTokenizer(in.readLine());
            int l,r;
            l = parseInt(tk.nextToken());
            r = parseInt(tk.nextToken());
            ar[i] = new pair(l,r,i);
        }
        if(n == 1){
            System.out.println("-1 -1");
            return;
        }
        sort(ar, Comparator.comparing((pair p)-> p.l).thenComparing((pair p)-> p.r));
        if(ar[1].l >= ar[2].l && ar[1].r <= ar[2].r){
            System.out.println(ar[1].idx+" "+ar[2].idx);
            return;
        }
        for (int i = 2; i < n; i++) {
            if(ar[i].l >= ar[i + 1].l && ar[i].r <= ar[i + 1].r) {
                System.out.println(ar[i].idx+" "+ ar[i + 1].idx);
                return;
            }
            if(ar[i].l >= ar[i - 1].l && ar[i].r <= ar[i - 1].r){
                System.out.println(ar[i].idx+" "+ ar[i - 1].idx);
                return;
            }
        }
        if(ar[n].l >= ar[n - 1].l && ar[n].r <= ar[n - 1].r){
            System.out.println(ar[n].idx+" "+ ar[n - 1].idx);
            return;
        }
        System.out.println("-1 -1");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.util.Arrays.sort;

public class C_Nested_Segments_2 {
    static class pair{
        int l,r,idx;
        public pair(int l,int r,int idx){
            this.l = l;
            this.r = r;
            this.idx = idx;
        }
    }
    static int n;
    static pair []ar;
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk;
        n = parseInt(in.readLine());
        ar = new pair[n + 1];
        ar[0] = new pair(0,0,0);
        for (int i = 1; i <= n; i++) {
            tk = new StringTokenizer(in.readLine());
            ar[i] = new pair(parseInt(tk.nextToken()),parseInt(tk.nextToken()),i);
        }

        sort(ar, Comparator.comparing((pair p)-> p.l).thenComparing((pair p)-> -p.r));
        int max = -1;
        int idxx = -1;
        for (int i = 1; i <= n; i++) {
            if(ar[i].r > max){
                max = ar[i].r;
                idxx = i;
                continue;
            }
            if(ar[i].r <= max){
                System.out.println(ar[i].idx+" "+ar[idxx].idx);
                return;
            }
        }
        System.out.println("-1 -1");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.util.Arrays.sort;

public class C_Nested_Segments {
    static class pair{
        int l,r,idx;
        public pair(int l,int r,int idx){
            this.l = l;
            this.r = r;
            this.idx = idx;
        }
    }
    static int n;
    static pair ar[];
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk;
        n = parseInt(in.readLine());
        ar = new pair[n + 1];
        ar[0] = new pair(0,0,0);
        for (int i = 1; i <= n; i++) {
            tk = new StringTokenizer(in.readLine());
            int l,r;
            l = parseInt(tk.nextToken());
            r = parseInt(tk.nextToken());
            ar[i] = new pair(l,r,i);
        }
        if(n == 1){
            System.out.println("-1 -1");
            return;
        }
        sort(ar, Comparator.comparing((pair p)-> p.l).thenComparing((pair p)-> p.r));
        if(ar[1].l >= ar[2].l && ar[1].r <= ar[2].r){
            System.out.println(ar[1].idx+" "+ar[2].idx);
        }
        for (int i = 2; i < n; i++) {
            if(ar[i].l >= ar[i + 1].l && ar[i].r <= ar[i + 1].r) {
                System.out.println(ar[i].idx+" "+ ar[i + 1].idx);
                return;
            }
            if(ar[i].l >= ar[i - 1].l && ar[i].r <= ar[i - 1].r){
                System.out.println(ar[i].idx+" "+ ar[i - 1].idx);
                return;
            }
        }
        if(ar[n].l >= ar[n - 1].l && ar[n].r <= ar[n - 1].r){
            System.out.println(ar[n].idx+" "+ ar[n - 1].idx);
            return;
        }
        System.out.println("-1 -1");
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static class Element implements Comparable<Element> {
		public int start , end , index;
		public Element(int start , int end , int index) {
			this.start = start;
			this.end = end;
			this.index = index;
		}
		public int compareTo(Element e) {
			if (this.start < e.start) {
				return - 1;
			} else if (this.start > e.start) {
				return 1;
			} else {
				return 0;
			}
		}
	}

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		List<Element> list = new ArrayList<>();
		for (i = 0;i < n;i ++) {
			int start = scan.nextInt() , end = scan.nextInt();
			list.add(new Element(start , end , i + 1));
		}
		Collections.sort(list);
		int end = list.get(0).end , index1 = list.get(0).index , index2 = - 1;
		for (i = 1;i < list.size();i ++) {
			if (list.get(i).end <= end) {
				index2 = list.get(i).index;
				break;
			} else {
				index1 = list.get(i).index;
			}
		}
		if (index2 >= 0) {
			System.out.println(index2 + " " + index1);
		} else {
			System.out.println(String.format("%d %d" , - 1 , - 1));
		}

	}

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static class Element implements Comparable<Element> {
		public int start , end , index;
		public Element(int start , int end , int index) {
			this.start = start;
			this.end = end;
			this.index = index;
		}
		public int compareTo(Element e) {
			if (this.start < e.start) {
				return - 1;
			} else if (this.start > e.start) {
				return 1;
			} else {
				if (this.end > e.end) {
				    return - 1;
				} else if (this.end < e.end) {
				    return 1;
				} else {
				    return 0;
				}
			}
		}
	}

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		List<Element> list = new ArrayList<>();
		for (i = 0;i < n;i ++) {
			int start = scan.nextInt() , end = scan.nextInt();
			list.add(new Element(start , end , i + 1));
		}
		Collections.sort(list);
		int end = list.get(0).end , index1 = list.get(0).index , index2 = - 1;
		for (i = 1;i < list.size();i ++) {
			if (list.get(i).end <= end) {
				index2 = list.get(i).index;
				break;
			} else {
				index1 = list.get(i).index;
				end = list.get(i).end;
			}
		}
		if (index2 >= 0) {
			System.out.println(index2 + " " + index1);
		} else {
			System.out.println(String.format("%d %d" , - 1 , - 1));
		}

	}

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static class Element implements Comparable<Element> {
		public int start , end , index;
		public Element(int start , int end , int index) {
			this.start = start;
			this.end = end;
			this.index = index;
		}
		public int compareTo(Element e) {
			if (this.start < e.start) {
				return - 1;
			} else if (this.start > e.start) {
				return 1;
			} else {
				return 0;
			}
		}
	}

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		List<Element> list = new ArrayList<>();
		for (i = 0;i < n;i ++) {
			int start = scan.nextInt() , end = scan.nextInt();
			list.add(new Element(start , end , i + 1));
		}
		Collections.sort(list);
		int end = list.get(0).end , index1 = list.get(0).index , index2 = - 1;
		for (i = 1;i < list.size();i ++) {
			if (list.get(i).end <= end) {
				index2 = list.get(i).index;
				break;
			} else {
				index1 = i;
			}
		}
		if (index2 >= 0) {
			System.out.println(index2 + " " + index1);
		} else {
			System.out.println(String.format("%d %d" , - 1 , - 1));
		}

	}

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static class Element implements Comparable<Element> {
		public int start , end , index;
		public Element(int start , int end , int index) {
			this.start = start;
			this.end = end;
			this.index = index;
		}
		public int compareTo(Element e) {
			if (this.start < e.start) {
				return - 1;
			} else if (this.start > e.start) {
				return 1;
			} else {
				if (this.end < e.end) {
				    return - 1;
				} else if (this.end > e.end) {
				    return 1;
				} else {
				    return 0;
				}
			}
		}
	}

	public static void main(String[] args) throws Exception {

		Scanner scan = new Scanner(System.in);

		int i , n = scan.nextInt();
		List<Element> list = new ArrayList<>();
		for (i = 0;i < n;i ++) {
			int start = scan.nextInt() , end = scan.nextInt();
			list.add(new Element(start , end , i + 1));
		}
		Collections.sort(list);
		int end = list.get(0).end , index1 = list.get(0).index , index2 = - 1;
		for (i = 1;i < list.size();i ++) {
			if (list.get(i).end <= end) {
				index2 = list.get(i).index;
				break;
			} else {
				index1 = list.get(i).index;
				end = list.get(i).end;
			}
		}
		if (index2 >= 0) {
			System.out.println(index2 + " " + index1);
		} else {
			System.out.println(String.format("%d %d" , - 1 , - 1));
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o2.b.a - o1.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b) && list.get(i).a.equals(list.get(i+1).a)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            LinkedList<Pair<Integer, Integer>> list2 = new LinkedList<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list2.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list2.remove(0);
                } else {
                    list2.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o2.b.a - o1.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b) && list.get(i).a.equals(list.get(i+1).a)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            LinkedList<Pair<Integer, Integer>> list2 = new LinkedList<>();
            HashSet<Pair<Integer, Integer>> list3 = new HashSet<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list3.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list3.remove(pair.b);
                    list2.remove(0);
                } else {
                    list2.add(pair.b);
                    list3.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o2.b.a - o1.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            ArrayList<Pair<Integer, Integer>> list2 = new ArrayList<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list2.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list2.remove(pair.b);
                } else {
                    list2.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o1.b.a - o2.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            ArrayList<Pair<Integer, Integer>> list2 = new ArrayList<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list2.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list2.remove(pair.b);
                } else {
                    list2.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o2.b.a - o1.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b) && list.get(i).a.equals(list.get(i+1).a)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            ArrayList<Pair<Integer, Integer>> list2 = new ArrayList<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list2.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list2.remove(pair.b);
                } else {
                    list2.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a == -1)
                continue;
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class CodeForces {

    public static void main(String[] args) throws IOException {
        in.init(System.in);
        StringBuilder out = new StringBuilder();
        int n = in.nextInt();
        Pair<Integer, Integer> pairs[] = new Pair[n];
        ArrayList<Pair<Character, Pair<Integer, Integer>>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            pairs[i] = new Pair(in.nextInt(), in.nextInt());
            list.add(new Pair<>('s', pairs[i]));
            list.add(new Pair<>('e', pairs[i]));
        }
        if (n == 1) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        Collections.sort(list, new Comparator<Pair<Character, Pair<Integer, Integer>>>() {

            @Override
            public int compare(Pair<Character, Pair<Integer, Integer>> o1, Pair<Character, Pair<Integer, Integer>> o2) {
                int o1Val;
                int o2Val;
                int o1Type;
                int o2Type;
                if (o1.a == 's') {
                    o1Val = o1.b.a;
                    o1Type = 1;
                } else {
                    o1Val = o1.b.b;
                    o1Type = 2;
                }
                if (o2.a == 's') {
                    o2Val = o2.b.a;
                    o2Type = 1;
                } else {
                    o2Val = o2.b.b;
                    o2Type = 2;
                }
                if (o1Val != o2Val) {
                    return o1Val - o2Val;
                } else if (o1Type != o2Type) {
                    return o1Type - o2Type;
                }
                if (o1Type == 1) {
                    return o2.b.b - o1.b.b;
                } else if (o1Type == 2) {
                    return o2.b.a - o1.b.a;
                }
                return 0;
            }
        });
        boolean flag = false;
        Pair<Integer, Integer> p1 = null;
        Pair<Integer, Integer> p2 = null;
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).b.a.equals(list.get(i + 1).b.a) && list.get(i).b.b.equals(list.get(i + 1).b.b)) {
                p1 = list.get(i).b;
                p2 = list.get(i + 1).b;
                flag = true;
                break;
            }
        }
        boolean ff = false;
        if (!flag) {
            ArrayList<Pair<Integer, Integer>> list2 = new ArrayList<>();
            for (Pair<Character, Pair<Integer, Integer>> pair : list) {
                if (list2.contains(pair.b)) {
                    if (list2.size() > 1) {
                        if (list2.get(0) != pair.b) {
                            p1 = list2.get(0);
                            p2 = pair.b;
                            ff = true;
                            break;
                        }
                    }
                    list2.remove(pair.b);
                } else {
                    list2.add(pair.b);
                }
            }
        }
        if(!ff && !flag) {
            System.out.print(String.format("%s %s\n", -1, -1));
            return;
        }
        int ii = -1;
        int jj = -1;
        for (int i = 0; i < n; i++) {
            if(pairs[i].a.equals(p1.a) && pairs[i].b.equals(p1.b)) {
                ii = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if(pairs[i].a.equals(p2.a) && pairs[i].b.equals(p2.b)) {
                jj = i;
                pairs[i].a = -1;
                pairs[i].b = -1;
                break;
            }
        }
        System.out.print(String.format("%s %s" ,jj+1,ii+1));
    }

}

class Pair<T, E> {

    T a;
    E b;

    public Pair(T a, E b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public String toString() {
        return String.format("(%s--> %s)", a, b);
    }

}

class in {

    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer(" ");
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static boolean hasNext() {
        return tokenizer.hasMoreTokens();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static int nextShort() throws IOException {
        return Short.parseShort(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.regex.Pattern;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amalev
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();

            TreeMap<TaskC.Segment, Integer> lmap = new TreeMap<>((a, b) -> {
                int c = Integer.compare(a.l, b.l);
                if (c != 0) {
                    return c;
                } else {
                    return -Integer.compare(a.r, b.r);
                }
            });

            TreeMap<TaskC.Segment, Integer> rmap = new TreeMap<>((a, b) -> {
                int c = Integer.compare(a.r, b.r);
                if (c != 0) {
                    return c;
                } else {
                    return -Integer.compare(a.l, b.l);
                }
            });

            for (int i = 0; i < n; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                TaskC.Segment s = new TaskC.Segment(l, r);
                if (lmap.containsKey(s)) {
                    int j = lmap.get(s);
                    out.print(i + 1);
                    out.print(" ");
                    out.print(j + 1);
                    return;
                } else {
                    lmap.put(s, i);
                    rmap.put(s, i);
                }
            }

            for (Map.Entry<TaskC.Segment, Integer> entryL : lmap.entrySet()) {
                rmap.remove(entryL.getKey());
                Map.Entry<TaskC.Segment, Integer> entryS = rmap.lowerEntry(entryL.getKey());
                if (entryS != null) {
                    out.print(entryS.getValue() + 1);
                    out.print(" ");
                    out.print(entryL.getValue() + 1);
                    return;
                }
            }
            out.print(-1);
            out.print(" ");
            out.print(-1);
        }

        static class Segment {
            final int l;
            final int r;

            Segment(int l, int r) {
                this.l = l;
                this.r = r;
            }

        }

    }

    static class FastScanner {
        final BufferedReader input;
        String[] buffer;
        int pos;
        final static Pattern SEPARATOR = Pattern.compile("\\s+");

        public FastScanner(InputStream inputStream) {
            input = new BufferedReader(new InputStreamReader(inputStream));
        }

        private String[] readAndSplit() {
            try {
                return SEPARATOR.split(input.readLine());
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }

        private String readToBuffer() {
            if (buffer == null || pos >= buffer.length) {
                buffer = readAndSplit();
                pos = 0;
            }
            return buffer[pos++];
        }

        public int nextInt() {
            return Integer.parseInt(readToBuffer());
        }

    }
}