#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main(){
	int n; cin>>n;
	int cnt=1000000001;
	rep(i,n){
		int a,p,x; cin>>a>>p>>x;
		if(x-a>0) cnt=min(cnt,p);
	}
	if(cnt!=1000000001) cout<<cnt<<endl;
	else cout<<-1<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define lowbit(x) (x&-x)
#define reg register
#define mkpr make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x3f3f3f3f;
const int mo=998244353;
const LL jzm=2333;
const int iv2=499122177;
const double Pi=acos(-1.0);
typedef pair<int,int> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
template<typename _T>
void print(_T x){if(x<0){x=(~x)+1;putchar('-');}if(x>9)print(x/10);putchar(x%10+'0');}
int n,minn;
struct ming{int a,p,x;}s[MAXN];
signed main(){
	read(n);minn=INF;
	for(int i=1;i<=n;i++)read(s[i].a),read(s[i].p),read(s[i].x);
	for(int i=1;i<=n;i++)if(s[i].x>s[i].a)minn=min(s[i].p,minn);
	if(minn>INF-1)puts("-1");else printf("%d\n",minn);
	return 0;
}
