#include <bits/stdc++.h>

using namespace std;

#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)


int main(){

    long n,a,b,c;

    cin >> n;

    long ans = LONG_MAX;

    rep(i,n)
    {
        cin >> a >> b >> c;
        long rem = c - a;
        if(rem > 0)
        {
            ans = min(ans, b);
        }
    }

    if(ans == LLONG_MAX) ans = -1;
    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define ALL(v) v.begin(),v.end()
#define sz(v) (ll)v.size()
const ll INF = 1e18;
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), p(n), x(n);
    for(ll i = 0; i < n; i++) cin >> a[i] >> p[i] >> x[i];
    ll ans = INF;
    for(ll i = 0; i < n; i++) {
        if(x[i]-a[i] > 0){
            chmin(ans, p[i]);
        }
    }
    cout << (ans==INF ? -1 : ans) << endl;

    return 0;
} 