#include <bits/stdc++.h>
using namespace std;
#define LL long long
//#define MOD 1000000007
#define MOD 998244353
#define INF 1000000000000000000
#define VE vector
#define VL vector<LL>
#define VVL VE<VL>
#define VVVL VE<VVL>
#define LD long double
#define PB push_back
#define POB pop_back
#define FOR(i,a,k) for(LL i=a;i<k;i++)
#define rep(i,k) FOR(i,0,k)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define coutl cout<<fixed<<setprecision(15)//

#define MI modint<MOD>
template<int mod>struct modint{
	int x;
	modint():x(0){}
	modint(LL n):x(n>=0?n%mod:(mod-(-n)%mod)%mod){}
	modint &operator+=(const modint &n){if((x+=n.x)>=mod)x-=mod;return *this;}
	modint &operator-=(const modint &n){if((x+=mod-n.x)>=mod)x-=mod;return *this;}
	modint &operator++(){*this+=1;return *this;}
  modint &operator--(){*this-=1;return *this;}
	modint &operator*=(const modint &n){x=(int)((LL)x*n.x%mod);return *this;}
	modint &operator/=(const modint &n){*this*=n.inv();return *this;}
	modint operator-()const{return modint(-x);}
	modint operator+(const modint &n)const{return modint(*this)+=n;}
	modint operator-(const modint &n)const{return modint(*this)-=n;}
	modint operator++(int){modint ret(*this);*this+=1;return ret;}
  modint operator--(int){modint ret(*this);*this-=1;return ret;}
	modint operator*(const modint &n)const{return modint(*this)*=n;}
	modint operator/(const modint &n)const{return modint(*this)/=n;}
	bool operator<(const modint &n)const{return x<n.x;}
	bool operator>(const modint &n)const{return x>n.x;}
	bool operator<=(const modint &n)const{return x<=n.x;}
	bool operator>=(const modint &n)const{return x>=n.x;}
	bool operator!=(const modint &n)const{return x!=n.x;}
	bool operator==(const modint &n)const{return x==n.x;}
	friend istream &operator>>(istream &is,modint &n){LL l;is>>l;n=modint<mod>(l);return is;}
	friend ostream &operator<<(ostream &os,const modint &n){return os<<n.x;}
	int getmod(){return mod;}
	modint inv()const{int a=x,b=mod,c=1,d=0,n;while(b){n=a/b;swap(a-=n*b,b);swap(c-=n*d,d);}return modint(c);}
	modint pow(LL n)const{modint ret(1),m(x);while(n){if(n&1)ret*=m;m*=m;n>>=1;}return ret;}
};

VL yakusuu(LL N){
	LL M=0;
	VL ret;
	for(LL i=0; i<N; i++){
		M++;
		if(M>N/M){
			for(LL i=0; i<N; i++){
				M--;
				if(M==0){
					return ret;
				}
				if(M*M==N){
					continue;
				}
				if(N%M==0){
					ret.PB(N/M);
				}
			}
		}
	  if(N%M==0){
		  ret.PB(M);
		}
	}
	return ret;
}

LL nanjo(LL a,LL n){//aのn乗  N=nanjo(a,n)A
	LL ret=1;
	for(LL i=0;i<n;i++){
		ret*=a;
	}
	return ret;
}

void YesNo(bool f){
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

LL kakuketa(LL n){//各桁の和を求める
	LL a=0;
	while(n>0){
		a=a+n%10;
		n=n/10;
	}
	return a;
}

int main(){
	LL N,ans=1000000001;
	cin>>N;
	VL A(N),P(N),X(N);
	rep(i,N){
		cin>>A[i]>>P[i]>>X[i];
	}
	rep(i,N){
		if(X[i]-A[i]>0){
			if(ans>=P[i]){
				ans=P[i];
			}
		}
	}
	if(ans==1000000001){
		cout<<-1<<endl;
	}
	else{
		cout<<ans<<endl;
	}
	/*LL K,ans=0;
	cin>>K;
	ans=K-2;//全部同じ数だった場合
	if(K>=4){
		ans+=(1+(K-2)/2)*K/2*3;//２つ同じ数があった場合
	}
	if(K>=6){
		ans+=(1+(K/2+1)*K/6)**6;
	}
	cout<<ans<<endl;
	LL N,M,T,ans=0;
	cin>>N>>M>>T;
	ans=N;
	VL A(M),B(M);
	rep(i,M){
		cin>>A[i]>>B[i];
	}
	rep(i,M){
		ans=ans-A[i]+A[i-1];
		if(ans<=0){
			cout<<"No"<<endl;
			break;
		}
		ans=ans+(B[i]-A[i]);
		if(ans>=M){
			ans=N;
		}
	}
	cout<<"Yes"<<endl;*/
}

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

int main(){
  int N, A, P, X, x = 1000000000;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A >> P >> X;
    if(X - A > 0){
      x = min(P, x); 
    }
  }
  if(x == 1000000000) cout << -1 <<endl;
  else cout << x << endl;
  return 0;
}