#include <bits/stdc++.h>
#define int			long long
#define pb 			push_back
#define ppb 			pop_back
#define all(x)			(x).begin(),(x).end()
#define w(x) 			int x; cin>>x; while(x--) 
#define fr 			first 
#define sc			second
#define sz(x)		 	(int) ( (x).size() )
#define pii			pair<int,int>
using namespace std;
int INF = 1e18+10 ;
int neg = - 1e9; 
const double epsilon = 1e-6; 
const int64_t M= 1e9 + 7;
const int N =(int)(1e6); 
//~ using u128 = __uint128_t;
// segment tree
void cpc(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(NULL);
}
  //~ bool seive[N];
    //~ vector<int>v; 
	//~ void seeve() {

			//~ seive[1] = 1; seive[0] = 1; 
			//~ for(int i = 2; i*i <= N; i++) { 
				//~ if ( seive[i] ) continue; 
				//~ for(int j = i; j*i <=N; j++) {
					//~ seive[i*j] = 1; 
				//~ }
			//~ }
		//~ for(int i = 0; i<(int)(1e5); i++) if ( seive[i] == 0 ) v.push_back(i*i);
		
	//~ }

int power(long long a, long long n, long long m = M) { 
    	a = a % m; 
    	long long prod = 1; 
    	while(n) { 
    		if (n & 1) prod = prod * a % m; 
    		a = a * a % m; 
    		n/=2; 
    	}
    	return prod; 
}


int32_t main(){
	cpc();
   int n; cin >> n; 
	int ans = 1e18; 
   for(int i = 0; i < n; i++){
	   int a, b, c; cin >> a >> b >> c; 
	   if ( c > a) ans = min(ans, b); 
   }
   if ( ans == 1e18) cout << "-1\n"; 
   else cout << ans << '\n'; 
   
	
}




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

const ll MX = 1000000000;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n), p(n), x(n);
  rep(i, n) cin >> a[i] >> p[i] >> x[i];

  ll ans = MX;
  rep(i, n)
  {
    int m = x[i] - a[i];
    if (m > 0)
    {
      ans = min(ans, p[i]);
    }
  }
  if (ans == MX)
  {
    cout << -1 << endl;
    return 0;
  }

  cout << ans << endl;

  return 0;
}