#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf LLONG_MAX
#define int long long

signed main(void)
{
	int n; cin >> n;
	int ans = -1;
	rep (i, n)
	{
		int a, p, x;
		cin >> a >> p >> x;
		int tmp;
		x -= a;
		if (x > 0 && (ans > p || ans == -1)) ans = p;
	}
	cout << ans << endl;
}

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

int main() {
int a ;
cin>>a;


vector<vector<int>> s(a,vector<int>(3));

for(int i =0;i<a;i++){
    
    for(int j =0;j<3;j++){
        
cin>>s.at(i).at(j);


     }}
     
    
     int ans=s.at(0).at(1);
     bool bo =true;
     for(int i =0;i<a;i++){
         
         if(s.at(i).at(2)-s.at(i).at(0)>0){
             
             
             ans=min(s.at(i).at(1),ans);
            bo=false;
         }
     }
     
     if(!bo)cout<<ans<<endl;
     
     if(bo)cout<<"-1"<<endl;
}
