#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for(LL i=0;i<(n);i++)

int main()
{
   LL n;
   LL min = -1;
   LL a, p, x;
   LL remaind;

   cin >> n;

   rep(i,n){

       cin >> a >> p >> x;

       remaind = x - a;

       if(remaind > 0){
           if(min == -1 || min > p)
                min = p;
       }

   }

   cout << min << endl;

    return 0;
}
// auther : chotathanos
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector< pair<int, int> > vpii;
#define MOD 1000000007
#define PI 3.14159265358979323
#define nl "\n"
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i=0; i<n; i++)
#define rep(i, a, b) for (int i=a; i<=b; i++)
#define ipARR(a, n) for (int i=0; i<n; i++) cin >> a[i];
#define opARR(a, n) for (int i=0; i<n; i++)cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

void solve() {
    int n;
    cin >> n;
    int a,x,p;
    int ans = INT_MAX;
    FOR(i,n) {
        cin >> a >> p >> x;
        if(a < x) ans = min(ans,p);
    }
    if(ans==INT_MAX) cout << -1;
    else cout << ans;
}
 
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	int tc = 1;
    // cin >> tc;
	while(tc--)
	solve();
	return 0;
}

