#include<bits/stdc++.h>
#define rg register 
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i ) 
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )  
#define dou double  
using namespace std ; 
void upd( int &x , int y ) {   
  if( x == -1 ) x = y ; 
  else x = min( x , y ) ;  
} 
signed main( ) { 
  ios::sync_with_stdio(false) ; 
  cin.tie(0) ;  
  int n , ans = -1 , a , b , c ; 
  cin >> n ; 
  fp( i , 1 , n ) { 
    cin >> a >> b >> c ; 
	if( a < c ) upd( ans , b ) ;   
  } 
  cout << ans << '\n' ; 
  return 0 ; 
} 

#include<bits/stdc++.h>
using namespace std;
#define en      '\n'
#define endl    '\n'
#define ll      long long signed
#define pb      push_back
#define append  push_back
#define all(v)  (v).begin(),(v).end()
#define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k)
#define fori(a) for(int i=0; i<a; i++)
#define forj(a) for(int j=0; j<a; j++)
#define fork(a) for(int k=0; k<a; k++)
#define MOD     1000000007
#define MAX     1000010
#define mset(a,s,k) memset(a,k,s*sizeof(a[0]))
#define ff      first
#define ss      second
#define __      <<" "<<
#define _       <<en

ll pow_(ll a,ll e,ll m=MOD){ll r=1;while(e){if(e&1)r=r*a%m;a=a*a%m;e>>=1;}return r;} 
int inv(ll a) {return int(pow_(a,MOD-2,MOD));}int add(ll a, ll b){return (a+b+MOD)%MOD;} int mul(ll a, ll b)
{return (MOD+a*b%MOD)%MOD;}int di(ll a, ll b){return mul(a,inv(b));}ll  ceil(ll a,ll b){return a/b+(a%b!=0);}
template<typename T1,typename T2>ostream&operator<<(ostream&O,pair<T1,T2>a){O<<"( ";O<<a.ff<<", "<<a.ss;O<<" )";return O;}
template<typename T>ostream&operator<<(ostream&O,vector<T>V){O<<"[ ";fori(V.size())O<<V[i]<<(i==V.size()-1?"":", ");O<<" ]";return O;}
template<typename T>ostream&operator<<(ostream&O,set<T>S){O<<"{ ";for(T i:S)O<<i<<", ";O<<" }";return O;}
template<typename T1,typename T2>ostream&operator<<(ostream&O,map<T1,T2>S){O<<"{ ";for(auto i:S)O<<i<<", ";O<<" }";return O;}
template<typename T=int>class print{public:vector<T>V;print(vector<T>v){V=v;cout<<" <"<<V<<"> ";}
print(T*x,int n){fori(n)V.push_back(x[i]);cout<<" <"<<V<<"> ";}friend ostream&operator<<(ostream&O,print p){return O;}};

#define vi vector<int>
#define tp pair<int,int>
#define ar array<int,4>

ar arr[MAX]; int N;
void reset();

int solve(){
    cin>>N;
    reset();
    fori(N){
        int a,b,c; cin>>a>>b>>c;
        arr[i]={b,a,c};
    }
    sort(arr,arr+N);
    bool f=1;
    fori(N){
        if(arr[i][1]<arr[i][2]){
            cout<<arr[i][0];
            f=false;
            break;
        }
    }
    if(f) cout<<-1;
    cout<<endl;
    // fori(N){ cin>>arr[i];}
    // print<int>(arr,N);
    return 0;
}

void reset(){

    
    // Clear Vectors, maps, sets
    // Set default values of arr
}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
        // cout<<solve()<<en;
        // cout<<(solve()?"Yes":"No")<<endl;
    }
    return 0;
}

