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

int main (){
    int n;
    cin >> n;
    ll ans = -1;
    rep(i, n){
        ll a, p, x;
        cin >> a >> p >> x;

        if(x - a > 0){
            if(ans==-1)
                ans = p;
            else if(ans>p)
                ans=p;
        }
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007ll
#define PI 3.14159265359
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a,b,c,d;
int32_t main(){
CODE_START;
cin>>a>>b>>c>>d;
cout<<b-c<<endl;
}
