#include<bits/stdc++.h>
int main()
{
    int n;
    int c=0,A,P,X,t=INT_MAX;
    scanf("%d",&n);
    while (n--)
    {
        scanf("%d %d %d",&A,&P,&X);
        if(A-X<0)
        {
            t=P<t?P:t;
            c=1;
        }
    }
    if(c==1)
        printf("%d",t);
    else
        printf("-1");
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    const int INF = 1001001001;
    int ans = INF;
    rep(i, n)
    {
        int a, p, x;
        cin >> a >> p >> x;
        if(x-a >= 1)
            ans = min(ans, p);
    }
    if(ans==INF)
        ans = -1;
    cout << ans << endl;
}
