#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;

  long long A[N],P[N],X[N];
  for (long i = 0; i < N; i++) {
      cin >> A[i] >> P[i] >> X[i];
  }

  long long price = 2000000000;

  for (long i = 0; i < N; i++) {
      if (X[i] > A[i]) {
          price = min(price,P[i]); 
      }
  }
  
  if (price == 2000000000) {
    cout << -1 <<endl;      
  }else{
      cout << price <<endl;
  }
}
// Author : Chinmay JHa @chinmayajha
// 
// Problem: B - Play Snuke
// Contest: AtCoder - Caddi Programming Contest 2021(AtCoder Beginner Contest 193)
// URL: https://atcoder.jp/contests/abc193/tasks/abc193_b
// Date / Time: 02-04-2021 18:58:24


#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t = 1;
	// cin >> t;
	while (t--) {
        lli n;cin>>n;
        vector<vector<lli>> a(n);
        // vector<lli> d(n);
        lli minn = 1e11;
        for(lli i = 0;i<n;++i){
            vector<lli> temp(3);
            cin >> temp[0]>>temp[1]>>temp[2];
            a[i] = temp;
        }
        sort(a.begin(),a.end());
        for(lli i = 0;i < n;++i){
            // minutes = a[i][0];
            // price = a[i][1];
            // stock = minutes*i + 0.5;
            
            float stock = a[i][2] - a[i][0];
            if(stock>=1){
                minn = min(minn, a[i][1]);
                // cout << a[i][1] << " ";
            } else {
                continue;
            }
        }
        if(minn == 1e11){
            cout << "-1\n";
        } else {
            cout << minn << "\n";
        }
	}

}