#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define FileIO freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)

#define Rep(var, a, b) for (int var = a; var <= b; var++)
#define For(var, a, b) for (int var = a; var < b; var++)
#define Forr(var, a, b) for (int var = a; var >= b; var--)
#define Foreach(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define db(x) { cout << #x << " = " << x << endl; }

#define pii pair<int, int>
#define pll pair<ll, ll>
#define mk(x, y) make_pair(x, y)

const ll MAX = 3 * 1e5 + 10;
const ll INF = 3 * 1e18 + 10;

bool mycompare(const pii &a, const pii &b) {
    if (a.first == b.first) return a.second >= b.second;
    return a.first < b.first;
}

int main() {
    FastIO;
    // FileIO;
    int n, l, r;
    pair<int, int> a[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        a[i] = pair<int, int>(l, r);
    }
    sort(a, a + n, mycompare);
    int j = 0;
    int i = 1;
    while (i < n) {
        if (a[j].second >= a[i].second) {
            cout << i + 1 << " " << j + 1;
            return 0;
        } else {
            j = i;
            i++;
        }
    }
    cout << "-1 -1";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define FileIO freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)

#define Rep(var, a, b) for (int var = a; var <= b; var++)
#define For(var, a, b) for (int var = a; var < b; var++)
#define Forr(var, a, b) for (int var = a; var >= b; var--)
#define Foreach(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define db(x) { cout << #x << " = " << x << endl; }

#define pii pair<int, int>
#define pll pair<ll, ll>
#define mk(x, y) make_pair(x, y)

const ll MAX = 3 * 1e5 + 10;
const ll INF = 3 * 1e18 + 10;

class Node {
public:
    int index;
    int first;
    int second;
    void setData(int index, int first, int second) {
        this->index = index;
        this->first = first;
        this->second = second;
    }
};

bool mycompare(const Node &a, const Node &b) {
    if (a.first == b.first) return a.second >= b.second;
    return a.first < b.first;
}

int main() {
    FastIO;
    // FileIO;
    int n, l, r;
    Node a[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        a[i].setData(i + 1, l, r);
    }
    sort(a, a + n, mycompare);
    int j = 0;
    int i = 1;
    while (i < n) {
        if (a[j].second >= a[i].second) {
            cout << a[i].index << " " << a[j].index;
            return 0;
        } else {
            j = i;
            i++;
        }
    }
    cout << "-1 -1";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 300005;

struct Segment {
    int index, first, second;
    bool operator < (const Segment &rhs) const {
        return ((first == rhs.first && second >= rhs.second) || first < rhs.first);
    }
};

Segment a[MAX];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 300005;

struct Segment {
    int index, first, second;
    bool operator < (const Segment &rhs) const {
        return ((first == rhs.first && second >= rhs.second) || first < rhs.first);
    }
};

Segment a[MAX];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; ++i)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 300005;
int n;
Segment a[MAX];

struct Segment {
    int index, first, second;
    bool inline operator < (const Segment &rhs) const {
        return (first < rhs.first || (first == rhs.first && second >= rhs.second));
    }
};

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 300005;
const ll INF = 3 * 1e18 + 10;

struct Segment {
    int index;
    int first;
    int second;
    bool inline operator < (const Segment &rhs) const {
        return (first < rhs.first || (first == rhs.first && second >= rhs.second));
    }
};

int main() {
    int n, l, r;
    Segment a[MAX];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MAX = 300005;

struct Segment {
    int index, first, second;
    int operator < (const Segment &rhs) const {
        return ((first == rhs.first && second > rhs.second) || first < rhs.first);
    }
};

Segment a[MAX];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; ++i)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 300005;

struct Segment {
    int index, first, second;
    bool inline operator < (const Segment &rhs) const {
        return (first < rhs.first || (first == rhs.first && second >= rhs.second));
    }
};

int n;
Segment a[MAX];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define FileIO freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)

#define Rep(var, a, b) for (int var = a; var <= b; var++)
#define For(var, a, b) for (int var = a; var < b; var++)
#define Forr(var, a, b) for (int var = a; var >= b; var--)
#define Foreach(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define db(x) { cout << #x << " = " << x << endl; }

#define pii pair<int, int>
#define pll pair<ll, ll>
#define mk(x, y) make_pair(x, y)

const ll MAX = 300005;
const ll INF = 3 * 1e18 + 10;

struct Segment {
    int index;
    int first;
    int second;
    bool inline operator < (const Segment &rhs) const {
        return (first < rhs.first || (first == rhs.first && second >= rhs.second));
    }
};

int main() {
    FastIO;
    // FileIO;
    int n, l, r;
    Segment a[MAX];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
        a[i].index = i + 1;
    }
    sort(a, a + n);
    for (int i = 1; i < n; i++)
        if (a[i - 1].second >= a[i].second) {
            printf("%d %d", a[i].index, a[i - 1].index);
            return 0;
        }
    printf("-1 -1");
    return 0;
}


// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define rep(i,n) for(int i = 0; i < n; i++)

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    time_t t1, t2;
    t1 = clock();

    int n;
    cin>>n;

    pair<int, pair<int, int> > s[n];

    for(int i = 0; i < n; i++)
    {
        cin>>s[i].ff>>s[i].ss.ff;
        s[i].ss.ss = i+1;
    }
    sort(s, s+n);

    int endi = 0;

    int i = 1;
    while(i < n)
    {
        while(s[i].ff > s[endi].ss.ff) endi++;
        if(s[i].ff >= s[endi].ff && s[i].ss.ff <= s[endi].ss.ff) return cout<<s[i].ss.ss<<" "<<s[endi].ss.ss<<endl,0;
        i++;
    }

    cout<<"-1 -1";

    t2 = clock();
    cerr << endl << "time taken: " << t2 - t1 << endl;

    return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	pair<int, int> l[n], r[n];
	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		l[i] = mp(x, i);
		r[i] = mp(y, i);
	}
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(l, l+n);
	sort(r, r+n);
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	set<pair<int, int> > s;
	pair<int, int> wtf[n], wtf2[n];
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		int lol = s.size();
		int x, y;
		cin >> x >> y;
		s.insert(mp(x, y));
		if(lol == s.size())
		{
			f = true;
			chx = x;
			chy = y;
		}
		// dbg(x, y);
		// cin >> x >> y;
		l[i] = mp(x, i);
		wtf[i] = mp(x, y);
		wtf2[i] = mp(y, x);
		r[i] = mp(y, i);
	}
	// dbg("f");
	if(f)
	{
		int pos1 = -1, pos2 = -1;
		for(int i = 0; i < n; i++)
		{
			if(l[i].ff == chx && r[i].ff == chy)
			{
				if(pos1 == -1)
				{
					pos1 = i;
				}
				else
				{
					pos2 = i;
					break;
				}
			}
		}
		cout << pos1+1 << " " << pos2+1 << endl;
		return 0;
	}
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n, mysort);
	sort(l, l+n);
	sort(wtf, wtf+n);
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		dbg(wtf[i].ff, wtf[i].ss);
		if(wtf[i].ff == wtf[i+1].ff)
		{
			if(wtf[i].ss > wtf[i+1].ss)
			{
				cout << i+2 << " " << i+1 << endl;
				return 0;
			}
			else if(wtf[i].ss < wtf[i+1].ss)
			{
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		dbg(wtf2[i].ff, wtf2[i].ss);
		if(wtf2[i].ff == wtf2[i+1].ff)
		{
			if(wtf2[i].ss < wtf2[i+1].ss)
			{
				cout << i+2 << " " << i+1 << endl;
				return 0;
			}
			else if(wtf2[i].ss > wtf2[i+1].ss)
			{
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		dbg(i, it, m[it]);
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define rep(i,n) for(int i = 0; i < n; i++)

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    time_t t1, t2;
    t1 = clock();

    int n;
    cin>>n;

    pair<int, pair<int, int> > s[n];
    map<int, int> fir;
    map<int, int> sec;

    for(int i = 0; i < n; i++)
    {
        cin>>s[i].ff>>s[i].ss.ff;
        s[i].ss.ss = i+1;

        if(fir[s[i].ff] > 0)
        {
            int x = fir[s[i].ff];

            if(s[x-1].ss.ff <= s[i].ss.ff) return cout<<x<<" "<<i+1,0;
            else return cout<<i+1<<' '<<x,0;
        }

        if(sec[s[i].ss.ff] > 0)
        {
            int x = sec[s[i].ss.ff];

            if(s[x-1].ff >= s[i].ff) return cout<<x<<" "<<i+1,0;
            else return cout<<i+1<<' '<<x,0;
        }

        fir[s[i].ff] = i+1;
        sec[s[i].ss.ff] = i+1;
    }
    sort(s, s+n);

    int endi = 0;

    int i = 1;
    while(i < n)
    {
        while(s[i].ff > s[endi].ff && s[i].ss.ff > s[endi].ss.ff && endi < i-1) endi++;
        if(s[i].ff >= s[endi].ff && s[i].ss.ff <= s[endi].ss.ff && endi != i) return cout<<s[i].ss.ss<<" "<<s[endi].ss.ss<<endl,0;

        trace(i, endi);
        i++;
    }

    cout<<"-1 -1";

    t2 = clock();
    cerr << endl << "time taken: " << t2 - t1 << endl;

    return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	set<pair<int, int> > s;
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		int lol = s.size();
		int x, y;
		cin >> x >> y;
		s.insert(mp(x, y));
		if(lol == s.size())
		{
			f = true;
			chx = x;
			chy = y;
		}
		// cin >> x >> y;
		l[i] = mp(x, i);
		r[i] = mp(y, i);
	}
	if(f)
	{
		int pos1 = -1, pos2 = -1;
		for(int i = 0; i < n; i++)
		{
			if(l[i].ff == chx && r[i].ff == chy)
			{
				if(pos1 == -1)
				{
					pos1 = i;
				}
				else
				{
					pos2 = i;
					break;
				}
			}
		}
		cout << pos1+1 << " " << pos2+1 << endl;
		return 0;
	}
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n, mysort);
	sort(l, l+n);
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	// set<pair<int, int> > s;
	pair<pair<int, int>, int> wtf[n], wtf2[n];
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		// int lol = s.size();
		int x, y;
		cin >> x >> y;
		// s.insert(mp(x, y));
		// if(lol == s.size())
		// {
		// 	f = true;
		// 	chx = x;
		// 	chy = y;
		// }
		// dbg(x, y);
		// cin >> x >> y;
		l[i] = mp(x, i);
		wtf[i] = mp(mp(x, y), i);
		wtf2[i] = mp(mp(y, x), i);
		r[i] = mp(y, i);
	}
	// dbg("f");
	// if(f)
	// {
	// 	int pos1 = -1, pos2 = -1;
	// 	for(int i = 0; i < n; i++)
	// 	{
	// 		if(l[i].ff == chx && r[i].ff == chy)
	// 		{
	// 			if(pos1 == -1)
	// 			{
	// 				pos1 = i;
	// 			}
	// 			else
	// 			{
	// 				pos2 = i;
	// 				break;
	// 			}
	// 		}
	// 	}
	// 	cout << pos1+1 << " " << pos2+1 << endl;
	// 	return 0;
	// }
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n);
	sort(l, l+n);
	sort(wtf, wtf+n);
	sort(wtf2, wtf2+n);
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf[i].ff, wtf[i].ss);
		if(wtf[i].ff.ff == wtf[i+1].ff.ff)
		{
			cout << wtf[i].ss + 1 << " " << wtf[i+1].ss + 1;
			return 0;
		}
	}
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf2[i].ff, wtf2[i].ss);
		if(wtf2[i].ff == wtf2[i+1].ff)
		{

			cout << wtf[i+1].ss +1 << " " << wtf[i].ss+1 << endl;
			return 0;
		}
	}
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		dbg(i, it, m[it]);
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	set<pair<int, int> > s;
	pair<int, int> wtf[n], wtf2[n];
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		int lol = s.size();
		int x, y;
		cin >> x >> y;
		s.insert(mp(x, y));
		if(lol == s.size())
		{
			f = true;
			chx = x;
			chy = y;
		}
		// dbg(x, y);
		// cin >> x >> y;
		l[i] = mp(x, i);
		wtf[i] = mp(x, y);
		wtf2[i] = mp(y, x);
		r[i] = mp(y, i);
	}
	// dbg("f");
	if(f)
	{
		int pos1 = -1, pos2 = -1;
		for(int i = 0; i < n; i++)
		{
			if(l[i].ff == chx && r[i].ff == chy)
			{
				if(pos1 == -1)
				{
					pos1 = i;
				}
				else
				{
					pos2 = i;
					break;
				}
			}
		}
		cout << pos1+1 << " " << pos2+1 << endl;
		return 0;
	}
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n, mysort);
	sort(l, l+n);
	sort(wtf, wtf+n);
	sort(wtf2, wtf2+n);
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		dbg(wtf[i].ff, wtf[i].ss);
		if(wtf[i].ff == wtf[i+1].ff)
		{
			if(wtf[i].ss > wtf[i+1].ss)
			{
				cout << i+2 << " " << i+1 << endl;
				return 0;
			}
			else if(wtf[i].ss < wtf[i+1].ss)
			{
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		dbg(wtf2[i].ff, wtf2[i].ss);
		if(wtf2[i].ff == wtf2[i+1].ff)
		{
			if(wtf2[i].ss < wtf2[i+1].ss)
			{
				cout << i+2 << " " << i+1 << endl;
				return 0;
			}
			else if(wtf2[i].ss > wtf2[i+1].ss)
			{
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		dbg(i, it, m[it]);
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	// set<pair<int, int> > s;
	pair<pair<int, int>, int> wtf[n], wtf2[n];
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		// int lol = s.size();
		int x, y;
		cin >> x >> y;
		// s.insert(mp(x, y));
		// if(lol == s.size())
		// {
		// 	f = true;
		// 	chx = x;
		// 	chy = y;
		// }
		// dbg(x, y);
		// cin >> x >> y;
		l[i] = mp(x, i);
		wtf[i] = mp(mp(x, y), i);
		wtf2[i] = mp(mp(y, x), i);
		r[i] = mp(y, i);
	}
	// dbg("f");
	// if(f)
	// {
	// 	int pos1 = -1, pos2 = -1;
	// 	for(int i = 0; i < n; i++)
	// 	{
	// 		if(l[i].ff == chx && r[i].ff == chy)
	// 		{
	// 			if(pos1 == -1)
	// 			{
	// 				pos1 = i;
	// 			}
	// 			else
	// 			{
	// 				pos2 = i;
	// 				break;
	// 			}
	// 		}
	// 	}
	// 	cout << pos1+1 << " " << pos2+1 << endl;
	// 	return 0;
	// }
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n);
	sort(l, l+n);
	sort(wtf, wtf+n);
	sort(wtf2, wtf2+n);
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf[i].ff, wtf[i].ss);
		if(wtf[i].ff.ff == wtf[i+1].ff.ff)
		{
			cout << wtf[i].ss + 1 << " " << wtf[i+1].ss + 1;
			return 0;
		}
	}
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf2[i].ff, wtf2[i].ss);
		if(wtf2[i].ff == wtf2[i+1].ff)
		{
			if(wtf2[i].ss >= wtf2[i+1].ss)
			{
				cout << wtf[i+1].ss +1 << " " << wtf[i].ss+1 << endl;
				return 0;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		dbg(i, it, m[it]);
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	// set<pair<int, int> > s;
	pair<pair<int, int>, int> wtf[n], wtf2[n];
	bool f = false;
	int chx, chy;
	for(int i = 0; i < n; i++)
	{
		// int lol = s.size();
		int x, y;
		cin >> x >> y;
		// s.insert(mp(x, y));
		// if(lol == s.size())
		// {
		// 	f = true;
		// 	chx = x;
		// 	chy = y;
		// }
		// dbg(x, y);
		// cin >> x >> y;
		l[i] = mp(x, i);
		wtf[i] = mp(mp(x, y), i);
		wtf2[i] = mp(mp(y, x), i);
		r[i] = mp(y, i);
	}
	// dbg("f");
	// if(f)
	// {
	// 	int pos1 = -1, pos2 = -1;
	// 	for(int i = 0; i < n; i++)
	// 	{
	// 		if(l[i].ff == chx && r[i].ff == chy)
	// 		{
	// 			if(pos1 == -1)
	// 			{
	// 				pos1 = i;
	// 			}
	// 			else
	// 			{
	// 				pos2 = i;
	// 				break;
	// 			}
	// 		}
	// 	}
	// 	cout << pos1+1 << " " << pos2+1 << endl;
	// 	return 0;
	// }
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n);
	sort(l, l+n);
	sort(wtf, wtf+n);
	sort(wtf2, wtf2+n);
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf[i].ff, wtf[i].ss);
		if(wtf[i].ff.ff == wtf[i+1].ff.ff)
		{
			cout << wtf[i].ss + 1 << " " << wtf[i+1].ss + 1;
			return 0;
		}
	}
	for(int i = 0; i < n-1; i++)
	{
		// dbg(l[i], r[i]);
		// dbg(wtf2[i].ff, wtf2[i].ss);
		if(wtf2[i].ff.ff == wtf2[i+1].ff.ff)
		{

			cout << wtf[i+1].ss +1 << " " << wtf[i].ss+1 << endl;
			return 0;
		}
	}
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		dbg(i, it, m[it]);
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define rep(i,n) for(int i = 0; i < n; i++)

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    time_t t1, t2;
    t1 = clock();

    int n;
    cin>>n;

    pair<int, pair<int, int> > s[n];
    map<int, int> fir;
    map<int, int> sec;

    for(int i = 0; i < n; i++)
    {
        cin>>s[i].ff>>s[i].ss.ff;
        s[i].ss.ss = i+1;

        if(fir[s[i].ff] > 0)
        {
            int x = fir[s[i].ff];

            if(s[x-1].ss.ff <= s[i].ss.ff) return cout<<x<<" "<<i+1,0;
            else return cout<<i+1<<' '<<x,0;
        }

        if(sec[s[i].ss.ff] > 0)
        {
            int x = fir[s[i].ss.ff];

            if(s[x-1].ff >= s[i].ff) return cout<<x<<" "<<i+1,0;
            else return cout<<i+1<<' '<<x,0;
        }

        fir[s[i].ff] = i+1;
        sec[s[i].ss.ff] = i+1;
    }
    sort(s, s+n);

    int endi = 0;

    int i = 1;
    while(i < n)
    {
        while(s[i].ff > s[endi].ff && s[i].ss.ff > s[endi].ss.ff && endi < i-1) endi++;
        if(s[i].ff >= s[endi].ff && s[i].ss.ff <= s[endi].ss.ff && endi != i) return cout<<s[i].ss.ss<<" "<<s[endi].ss.ss<<endl,0;

        trace(i, endi);
        i++;
    }

    cout<<"-1 -1";

    t2 = clock();
    cerr << endl << "time taken: " << t2 - t1 << endl;

    return 0;
}


// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define rep(i,n) for(int i = 0; i < n; i++)

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    time_t t1, t2;
    t1 = clock();

    int n;
    cin>>n;

    pair<int, pair<int, int> > s[n];

    for(int i = 0; i < n; i++)
    {
        cin>>s[i].ff>>s[i].ss.ff;
        s[i].ss.ss = i+1;
    }
    sort(s, s+n);

    int endi = 0;

    int i = 1;
    while(i < n)
    {
        while(s[i].ff > s[endi].ff && s[i].ss.ff > s[endi].ss.ff && endi < i-1) endi++;
        if(s[i].ff >= s[endi].ff && s[i].ss.ff <= s[endi].ss.ff && endi != i) return cout<<s[i].ss.ss<<" "<<s[endi].ss.ss<<endl,0;

        trace(i, endi);
        i++;
    }

    cout<<"-1 -1";

    t2 = clock();
    cerr << endl << "time taken: " << t2 - t1 << endl;

    return 0;
}


/*
author: orthodoxparadox
30-Apr-2018
20:25:40
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vpii vector<pair<int, int> >
#define vpll vector<pair<long long, long long> >
#define mll map<ll, ll>
#define mii map<int, int>
#define msi map<string, int>
#define msl map<string, ll>
#define umll unordered_map<ll, ll>
#define umii unordered_map<int, int>
#define umsi unordered_map<string, int>
#define umsl unordered_map<string, ll>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ")
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#else
#define dbg(...)
#endif

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

const int N = 3*1e5+10;
pair<int, int> l[N], r[N];

bool mysort(pair<int, int> a, pair<int, int> b)
{
	if(a.ff == b.ff)
	{
		return l[a.ss] > l[b.ss];
	}
	else
	{
		return a.ff < b.ff;
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		l[i] = mp(x, i);
		r[i] = mp(y, i);
	}
	pii p[n], q[n];
	p[n] = l[n];
	q[n] = r[n];
	bool flag = false;
	map<int, int> m;
	sort(r, r+n, mysort);
	sort(l, l+n);
	for(int i = 0; i < n; i++)
	{
		m[r[i].ss] = i;
	}
	int pos = -1;
	for(int i = 0; i < n; i++)
	{
		int it = l[i].ss;
		if(m[l[i].ss] > i)
		{
			pos = it;
			flag = true;
			break;
		}
	}
	for(int i = 0; i < n; i++)
	{
		dbg(i, r[i].ff, r[i].ss);
	}
	if(!flag)
	{
		cout << "-1 -1";
		return 0;
	}
	int pos2 = -1;
	for(int i = 0; i < n; i++)
	{
		if(i == pos)
			continue;
		if(p[i] <= p[pos] && q[i] >= q[pos])
		{
			pos2 = i;
			break;
		}
	}
	cout << pos2+1 << " " << pos+1;
	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
bool comp(pll left, pll right)
{
    return left.first >= right.first && right.first <= left.first;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    int n;
    cin >> n;
    vector<pair<long, long>> seg(n);
    long l, r;
    map<pll, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i] = {l, r};
        mp[{l, r}] = i;
    }
    stable_sort(seg.begin(), seg.end(), comp);
    for(int i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << mp[seg[i]] << " " << mp[seg[i + 1]];
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
bool comp(pll left, pll right)
{
    return left.first >= right.first && right.first <= left.first;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    int n;
    cin >> n;
    vector<pair<long, long>> seg(n);
    long l, r;
    map<pll, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i] = {l, r};
        mp[{l, r}] = i;
    }
    stable_sort(seg.begin(), seg.end(), comp);
    for(int i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << mp[seg[i]] << " " << mp[seg[i + 1];
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
typedef long long ll;
struct segm
{
    ll first, second;
    ll third;
};
bool comp(segm left, segm right)
{
    return left.first >= right.first && left.second<= right.second;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    freopen("in.txt", "r", stdin);

    ll n;
    cin >> n;
    vector<segm> seg(n);
    ll l, r;
    //map<pll, int>mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i].first = l;
        seg[i].second = r;
        seg[i].third = i + 1;
    }
    sort(begin(seg), end(seg), comp);
    for(ll i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << seg[i].third << " " << seg[i + 1].third;
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
typedef long ll;
struct segm
{
    ll first, second;
    ll third;
};

bool comp(segm left, segm right)
{
    return left.first >= right.first && left.second <= right.second;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    ll n;
    cin >> n;
    vector<segm> seg(n);
    ll l, r;
    //map<pll, int>mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i].first = l;
        seg[i].second = r;
        seg[i].third = i + 1;
    }
    sort(begin(seg), end(seg), comp);
    for(ll i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first || seg[i].second <= seg[i + 1].second)
           {
             cout << seg[i].third << " " << seg[i + 1].third;
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
bool comp(pll left, pll right)
{
    return left.first >= right.first && right.first <= left.first;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    int n;
    cin >> n;
    vector<pair<long, long>> seg(n);
    long l, r;
    map<pll, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i] = {l, r};
        mp[{l, r}] = i + 1;
    }
    stable_sort(seg.begin(), seg.end(), comp);
    for(int i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << mp[seg[i]] << " " << mp[seg[i + 1]];
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;

struct segm
{
    long first, second;
    int third;
};
bool comp(segm left, segm right)
{
    return left.first >= right.first && left.second<= right.second;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    int n;
    cin >> n;
    vector<segm> seg(n);
    long l, r;
    map<pll, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i].first = l;
        seg[i].second = r;
        seg[i].third = i + 1;
    }
    sort(seg.begin(), seg.end(), comp);
    for(int i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << seg[i].third << " " << seg[i + 1].third;
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
typedef long ll;
struct segm
{
    ll first, second;
    ll third;
};

bool comp(segm left, segm right)
{

    if(left.first == right.first)
        return left.second  < right.second;
     return left.first  > right.first;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    ll n;
    cin >> n;
    vector<segm> seg(n);
    ll l, r;
    //map<pll, int>mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i].first = l;
        seg[i].second = r;
        seg[i].third = i + 1;
    }
    sort(begin(seg), end(seg), comp);
//for(auto c: seg)
  //      cout << c.first << " "<< c.second << " " << c.third << "\n";
    for(ll i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << seg[i].third << " " << seg[i + 1].third;
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
bool comp(pll left, pll right)
{
    return left.first >= right.first && left.second<= right.second;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);

    int n;
    cin >> n;
    vector<pair<long, long>> seg(n);
    long l, r;
    map<pll, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i] = {l, r};
        mp[{l, r}] = i + 1;
    }
    stable_sort(seg.begin(), seg.end(), comp);
    for(int i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << mp[seg[i]] << " " << mp[seg[i + 1]];
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


//Author: Bishal Sarang
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
typedef pair<long, long> pll;
typedef long long ll;
struct segm
{
    ll first, second;
    ll third;
};
bool comp(segm left, segm right)
{
    return left.first >= right.first && left.second<= right.second;

}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(false);
   // freopen("in.txt", "r", stdin);

    ll n;
    cin >> n;
    vector<segm> seg(n);
    ll l, r;
    //map<pll, int>mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> l >> r;
        seg[i].first = l;
        seg[i].second = r;
        seg[i].third = i + 1;
    }
    sort(begin(seg), end(seg), comp);
    for(ll i = 0; i < n - 1; i++ )
    {
        if(seg[i].first >= seg[i + 1].first && seg[i].second <= seg[i + 1].second)
           {
             cout << seg[i].third << " " << seg[i + 1].third;
            return 0;
           }
    }
    cout << -1 << " " << -1;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<struct it> vs;
typedef vector<pair<int,int> > vpi;
struct it{
    int indx;
    int val;
    int st;
    int val2;
};
vpi A;
vs B;
int N;
vector<int> Fin;

bool by_val(struct it a1,struct it a2){
    return a1.val<a2.val;
}

bool check(int i,int j){
    if(A[i].fi>=A[j].fi&&A[i].se<=A[j].se) return true;
    return false;
}
bool palin(int i){
    if(Fin[i]==Fin[i+3]&&Fin[i+1]==Fin[i+2]) return true;
    return false;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
        struct it tmp1,tmp2;
        tmp1.indx = i;
        tmp2.indx = i;
        tmp1.st = 1; tmp2.st =0;
        tmp1.val = u;tmp2.val = v;tmp1.val2 = v; tmp2.val2 = u;
        B.pb(tmp1); B.pb(tmp2);
    }
    sort(B.begin(),B.end(),by_val);
    FOR(i,0,2*N-1){
        if(B[i].val==B[i+1].val&&B[i].indx!=B[i+1].indx){
            if((B[i].st*B[i+1].st==0) && (B[i].val2!=B[i].val && B[i+1].val2!=B[i+1].val)) continue;
            int u = B[i].indx, v = B[i+1].indx;
            if(!check(u,v)){
                int tmp = u;
                u  =v;
                v = tmp;
            }
            printf("%d %d",u+1,v+1);
            return 0;
        }
    }
    FOR(i,0,2*N)
        Fin.pb(B[i].indx);
    FOR(i,0,2*N-3){
        if(palin(i)){
            printf("%d %d",B[i+1].indx+1,B[i].indx+1);
            return 0;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;
struct it{
    int u,v,indx;
};
vector<struct it> A;
int N;
bool comp(struct it a1,struct it a2){
    if(a1.u==a2.u) return a1.v>=a2.v;
    return a1.u<a2.u;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        struct it tmp;
        tmp.u = u; tmp.v = v; tmp.indx = i+1;
        A.pb(tmp);
    }
    sort(A.begin(),A.end(),comp);
    int maxr = -1;
    int maxi = -1;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].v<=maxr){
            printf("%d %d",A[i].indx,maxi);
            return 0;
        }
        if(A[i].v>maxr){
            maxr = A[i].v;
            maxi = A[i].indx;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;
struct it{
    ll u,v;int indx;
};
vector<struct it> A;
int N;
bool comp(struct it a1,struct it a2){
    if(a1.u==a2.u) return a1.v>=a2.v;
    return a1.u<=a2.u;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        ll u,v;
        scanf("%lld %lld",&u,&v);
        struct it tmp;
        tmp.u = u; tmp.v = v; tmp.indx = i+1;
        A.pb(tmp);
    }
    sort(A.begin(),A.end(),comp);
    ll maxr = 0;
    int maxi = 0;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].v<=maxr){
            printf("%d %d",A[i].indx,maxi);
            return 0;
        }
        if(A[i].v>maxr){
            maxr = A[i].v;
            maxi = A[i].indx;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<struct it> vs;
typedef vector<pair<int,int> > vpi;
struct it{
    int indx;
    int val;
    int st;
};
vpi A;
vs B;
int N;
vector<int> Fin;

bool by_val(struct it a1,struct it a2){
    return a1.val<a2.val;
}

bool check(int i,int j){
    if(A[i].fi>=A[j].fi&&A[i].se<=A[j].se) return true;
    return false;
}
bool palin(int i){
    if(Fin[i]==Fin[i+3]&&Fin[i+1]==Fin[i+2]) return true;
    return false;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
        struct it tmp1,tmp2;
        tmp1.indx = i;
        tmp2.indx = i;
        tmp1.st = 1; tmp2.st =0;
        tmp1.val = u;tmp2.val = v;
        B.pb(tmp1); B.pb(tmp2);
    }
    sort(B.begin(),B.end(),by_val);
    FOR(i,0,2*N-1){
        if(B[i].val==B[i+1].val&&B[i].indx!=B[i+1].indx){
            if(((B[i].st==1&&B[i+1].st==0)||(B[i].st==0&&B[i+1].st==1)) && ((A[B[i].indx].se!=A[B[i].indx].fi && A[B[i+1].indx].se!=A[B[i+1].indx].fi))) continue;
            int u = B[i].indx, v = B[i+1].indx;
            if(!check(u,v)){
                int tmp = u;
                u  =v;
                v = tmp;
            }
            printf("%d %d",u+1,v+1);
            return 0;
        }
    }
    FOR(i,0,2*N)
        Fin.pb(B[i].indx);
    FOR(i,0,2*N-3){
        if(palin(i)){
            printf("%d %d",B[i+1].indx+1,B[i].indx+1);
            return 0;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;

vpi A;
int N;
bool comp(pair<int,int> a1,pair<int,int> a2){
    if(a1.fi==a2.fi) return a1.se>=a2.se;
    return a1.fi<a2.fi;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
    }
    sort(A.begin(),A.end(),comp);
    int maxr = 0;
    int maxi = -1;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].se<=maxr){
            printf("%d %d",i+1,maxi+1);
            return 0;
        }
        if(A[i].se>maxr){
            maxr = A[i].se;
            maxi = i;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<struct it> vs;
typedef vector<pair<int,int> > vpi;
struct it{
    int indx;
    int val;
    int st;
};
vpi A;
vs B;
int N;
vector<int> Fin;

bool by_val(struct it a1,struct it a2){
    return a1.val<a2.val;
}

bool check(int i,int j){
    if(A[i].fi>=A[j].fi&&A[i].se<=A[j].se) return true;
    return false;
}
bool palin(int i){
    if(Fin[i]==Fin[i+3]&&Fin[i+1]==Fin[i+2]) return true;
    return false;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
        struct it tmp1,tmp2;
        tmp1.indx = i;
        tmp2.indx = i;
        tmp1.st = 1; tmp2.st =0;
        tmp1.val = u;tmp2.val = v;
        B.pb(tmp1); B.pb(tmp2);
    }
    sort(B.begin(),B.end(),by_val);
    FOR(i,0,2*N-1){
        if(B[i].val==B[i+1].val&&B[i].indx!=B[i+1].indx){
            if(B[i].st!=1||B[i].st!=1) continue;
            int u = B[i].indx, v = B[i+1].indx;
            if(!check(u,v)){
                int tmp = u;
                u  =v;
                v = tmp;
            }
            printf("%d %d",u+1,v+1);
            return 0;
        }
    }
    FOR(i,0,2*N)
        Fin.pb(B[i].indx);
    FOR(i,0,2*N-3){
        if(palin(i)){
            printf("%d %d",B[i+1].indx+1,B[i].indx+1);
            return 0;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;
struct it{
    ll u,v;int indx;
};
vector<struct it> A;
int N;
bool comp(struct it a1,struct it a2){
    if(a1.u==a2.u) return a1.v>=a2.v;
    return a1.u<a2.u;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        ll u,v;
        scanf("%lld %lld",&u,&v);
        struct it tmp;
        tmp.u = u; tmp.v = v; tmp.indx = i+1;
        A.pb(tmp);
    }
    sort(A.begin(),A.end(),comp);
    ll maxr = -1;
    int maxi = -1;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].v<=maxr){
            printf("%d %d",A[i].indx,maxi);
            return 0;
        }
        if(A[i].v>maxr){
            maxr = A[i].v;
            maxi = A[i].indx;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<struct it> vs;
typedef vector<pair<int,int> > vpi;
struct it{
    int indx;
    int val;
    int st;
};
vpi A;
vs B;
int N;
vector<int> Fin;

bool by_val(struct it a1,struct it a2){
    return a1.val<a2.val;
}

bool check(int i,int j){
    if(A[i].fi>=A[j].fi&&A[i].se<=A[j].se) return true;
    return false;
}
bool palin(int i){
    if(Fin[i]==Fin[i+3]&&Fin[i+1]==Fin[i+2]) return true;
    return false;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
        struct it tmp1,tmp2;
        tmp1.indx = i;
        tmp2.indx = i;
        tmp1.st = 1; tmp2.st =0;
        tmp1.val = u;tmp2.val = v;
        B.pb(tmp1); B.pb(tmp2);
    }
    sort(B.begin(),B.end(),by_val);
    FOR(i,0,2*N-1){
        if(B[i].val==B[i+1].val&&B[i].indx!=B[i+1].indx){
            if((B[i].st==1&&B[i+1].st==1)||(B[i].st==0&&B[i+1].st==0)){
            int u = B[i].indx, v = B[i+1].indx;
            if(!check(u,v)){
                int tmp = u;
                u  =v;
                v = tmp;
            }
            printf("%d %d",u+1,v+1);
            return 0;
        }
    }
    }
    FOR(i,0,2*N)
        Fin.pb(B[i].indx);
    FOR(i,0,2*N-3){
        if(palin(i)){
            printf("%d %d",B[i+1].indx+1,B[i].indx+1);
            return 0;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;

vpi A;
int N;

int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
    }
    sort(A.begin(),A.end());
    int maxr = 0;
    int maxi = -1;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].se<=maxr){
            printf("%d %d",i+1,maxi+1);
            return 0;
        }
        if(A[i].se>maxr){
            maxr = A[i].se;
            maxi = i;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<pair<int,int> > vpi;
struct it{
    ll u,v;int indx;
};
vector<struct it> A;
int N;
bool comp(struct it a1,struct it a2){
    if(a1.u==a2.u) return a1.v>a2.v;
    return a1.u<a2.u;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        ll u,v;
        scanf("%lld %lld",&u,&v);
        struct it tmp;
        tmp.u = u; tmp.v = v; tmp.indx = i+1;
        A.pb(tmp);
    }
    sort(A.begin(),A.end(),comp);
    ll maxr = 0;
    int maxi = 0;
    FOR(i,0,N){
        //printf("%d %d\n",A[i].se,maxr);
        if(A[i].v<=maxr){
            printf("%d %d",A[i].indx,maxi);
            return 0;
        }
        if(A[i].v>maxr){
            maxr = A[i].v;
            maxi = A[i].indx;
        }
    }
    printf("-1 -1");
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define FOR(i,a,b) for(int i =a;i<b;i++)
using namespace std;
typedef vector<struct it> vs;
typedef vector<pair<int,int> > vpi;
struct it{
    int indx;
    int val;
    int st;
};
vpi A;
vs B;
int N;
vector<int> Fin;

bool by_val(struct it a1,struct it a2){
    return a1.val<a2.val;
}

bool check(int i,int j){
    if(A[i].fi>=A[j].fi&&A[i].se<=A[j].se) return true;
    return false;
}
bool palin(int i){
    if(Fin[i]==Fin[i+3]&&Fin[i+1]==Fin[i+2]) return true;
    return false;
}
int main() {
    scanf("%d",&N);
    FOR(i,0,N){
        int u,v;
        scanf("%d %d",&u,&v);
        A.pb({u,v});
        struct it tmp1,tmp2;
        tmp1.indx = i;
        tmp2.indx = i;
        tmp1.st = 1; tmp2.st =0;
        tmp1.val = u;tmp2.val = v;
        B.pb(tmp1); B.pb(tmp2);
    }
    sort(B.begin(),B.end(),by_val);
    FOR(i,0,2*N-1){
        if(B[i].val==B[i+1].val&&B[i].indx!=B[i+1].indx){
            if(((B[i].st==1&&B[i+1].st==0)||(B[i].st==0&&B[i+1].st==1)) && ((A[B[i].indx].se!=B[i].val && A[B[i+1].indx].se!=B[i+1].val))) continue;
            int u = B[i].indx, v = B[i+1].indx;
            if(!check(u,v)){
                int tmp = u;
                u  =v;
                v = tmp;
            }
            printf("%d %d",u+1,v+1);
            return 0;
        }
    }
    FOR(i,0,2*N)
        Fin.pb(B[i].indx);
    FOR(i,0,2*N-3){
        if(palin(i)){
            printf("%d %d",B[i+1].indx+1,B[i].indx+1);
            return 0;
        }
    }
    printf("-1 -1");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=q[1].z;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                printf("%d %d\n",q[i].z,id);
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r<b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)cin>>q[i].l>>q[i].r,q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=1;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                cout<<q[i].z<<' '<<id<<endl;
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        cout<<-1<<' '<<-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)cin>>q[i].l>>q[i].r,q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=1;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                cout<<q[i].z<<' '<<id<<endl;
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        cout<<-1<<' '<<-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        for(int i=2;i<=n;i++){
            if(q[i].r<=q[i-1].r){
                printf("%d %d\n",q[i].z,q[i-1].r);
                return 0;
            }
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
        cin>>n;
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=q[1].z;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                printf("%d %d\n",q[i].z,id);
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
            //cout<<ans<<endl;
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l==b.l)return a.r>b.r;
     else return a.l<b.l;
}
int main()
{
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        for(int i=2;i<=n;i++){
            if(q[i].r<=q[i-1].r){
                printf("%d %d\n",q[i].z,q[i-1].z);
                return 0;
            }
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)cin>>q[i].l>>q[i].r,q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=1;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                cout<<q[i].z<<' '<<id<<endl;
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        cout<<-1<<' '<<-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
   int l,r;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r<b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)cin>>q[i].l>>q[i].r;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=1;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                cout<<i<<' '<<id<<endl;
                return 0;
            }
            else {
                ans=q[i].r;
                id=i;
            }
        }
        cout<<-1<<' '<<-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
        cin>>n;
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=q[1].z;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                printf("%d %d\n",q[i].z,id);
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
            cout<<ans<<endl;
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        for(int i=2;i<=n;i++){
            if(q[i].r<=q[i-1].r){
                printf("%d %d\n",q[i].z,q[i-1].z);
                return 0;
            }
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=q[1].z;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                printf("%d %d\n",q[i].z,id);
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        printf("-1 -1\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].z=i;
        sort(q+1,q+n+1,cmp);
        for(int i=2;i<=n;i++){
            if(q[i].r<=q[i-1].r){
                printf("%d %d\n",q[i].z,q[i-1].z);
                return 0;
            }
        }
        printf("-1 -1\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
struct node{
   int l,r,z;
}q[maxn];
bool cmp(struct node a,struct node b){
     if(a.l!=b.l)return a.l<b.l;
     else if(a.r!=b.r)return a.r>b.r;
}
int main()
{
    int n;
    while(cin>>n){
        for(int i=1;i<=n;i++)cin>>q[i].l>>q[i].r,q[i].z=i;
        sort(q+1,q+n+1,cmp);
        int ans=q[1].r;
        int id=q[1].z;
        for(int i=2;i<=n;i++){
            if(q[i].r<=ans){
                cout<<q[i].z<<' '<<id<<endl;
                return 0;
            }
            else {
                ans=q[i].r;
                id=q[i].z;
            }
        }
        cout<<-1<<' '<<-1<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r,c=0,pre=-1;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        left=0;
        right=i-1;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(p[mid].second.first>=r)
            {
                cout << i+1 << " " << p[mid].second.second+1;
                return 0;
            }
            else
            {
                right=mid;
            }
            if(mid==pre)
                c++;
            pre=mid;
            if(c>2)
                right=left-1;
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        left=0;
        right=i-1;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(p[mid].second.first>=r)
            {
                cout << p[i].second.second+1 << " " << p[mid].second.second+1;
                return 0;
            }
            else
            {
                right=mid-1;
            }
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r,c=0,pre=-1;
    for(i=0;i<n-1;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        if((p[i+1].first>=l)&&(p[i+1].second.first<=r)){
            cout << p[i+1].second.second+1 << " " << p[i].second.second+1;
            return 0;
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first >= b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r,c=0,pre=-1;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        left=0;
        right=i-1;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(p[mid].second.first>=r && p[mid].first<=l)
            {
                cout << i+1 << " " << p[mid].second.second+1;
                return 0;
            }
            else
            {
                right=mid;
            }
            if(mid==pre)
                c++;
            pre=mid;
            if(c>2)
                right=left-1;
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r,c=0,pre=-1;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        left=0;
        right=i-1;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(p[mid].second.first>=r && p[mid].first<=l)
            {
                cout << i+1 << " " << p[mid].second.second+1;
                return 0;
            }
            else
            {
                right=mid;
            }
            if(mid==pre)
                c++;
            pre=mid;
            if(c>2)
                right=left-1;
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r,c=0,pre=-1;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        if(p[0].second.first >= r)
        {
            cout << i+1 << " " << p[0].second.second+1;
            return 0;
        }
    }
    cout << -1 << " " << -1;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007

bool compare(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second.first > b.second.first;
    return false;
}

int main()
{
    FAST;
    int n;
    cin >> n;
    pair<int,pair<int,int> > p[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second=i;
    }
    sort(p,p+n,compare);
    int mid,left,right,l,r;
    for(i=1;i<n;i++)
    {
        l=p[i].first;
        r=p[i].second.first;
        left=0;
        right=i-1;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(p[mid].second.first>=r)
            {
                cout << i+1 << " " << p[mid].second.second+1;
                return 0;
            }
            else
            {
                right=mid-1;
            }
        }
    }
    cout << -1 << " " << -1;
}