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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), p(n), x(n);
    rep(i, 0, n) cin >> a[i] >> p[i] >> x[i];

    ll ans = 100100100100;
    ll karians = 100100100100;
    bool kau = false;
    rep(i, 0, n) {
        x[i] -= a[i];
        if(x[i] > 0) {
            karians = p[i];
            kau = true;
        }
        ans = min(ans, karians);
        karians = 100100100100;
    }

    if(kau) cout << ans << endl;
    else cout << "-1" << endl;
}
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7
const long long MOD = 998244353;

int main() {
    int N, A, P, X;
    cin >> N;
    int ans = INF;
    for (int i = 0; i < N; i++) {
        cin >> A >> P >> X;
        if (X - A > 0) {
            ans = min(ans, P);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}