1 #include
2 using namespace std;
3 #define lson l,mid,rt<<1
4 #define rson mid+1,r,rt<<1|1
5 #define IT set::iterator
6 #define sqr(x) ((x)*(x))
7 #define pb push_back
8 #define eb emplace_back
9 #define maxn 200005
10 #define eps 1e-8
11 #define pi acos(-1.0)
12 #define rep(k,i,j) for(int k=i;k13 typedef long long ll;
14 typedef pair<int,int> pii;
15 typedef pairpll;
16 typedef pairint> pli;
17 typedef pairint,string>,pii> ppp;
18 typedef unsigned long long ull;
19 const long long MOD=998244353;
20 const double oula=0.57721566490153286060651209;
21 using namespace std;
22
23
24 vectorint,pair<int,int> > >ve;
25
26 bool cmp(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b){
27 if(a.second.first==b.second.first) return a.second.second>b.second.second;
28 return a.second.first<b.second.first;
29 }
30
31 int main(){
32 std::ios::sync_with_stdio(false);
33 int n;
34 cin>>n;
35 int x,y;
36 for(int i=1;i<=n;i++){
37 cin>>x>>y;
38 ve.pb({i,{x,y}});
39 }
40 sort(ve.begin(),ve.end(),cmp);
41 int L=ve[0].second.first,R=ve[0].second.second,pos=ve[0].first;
42 int flag=0;
43 for(int i=1;i){
44 if(L<=ve[i].second.first&&R>=ve[i].second.second){
45 cout<" "<endl;
46 return 0;
47 }
48 L=ve[i].second.first,R=ve[i].second.second,pos=ve[i].first;
49 }
50 if(!flag){
51 cout<<-1<<" "<<-1<<endl;
52 }
53 }