#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int> > sunuke(N, vector<int>(3));
    for(int i = 0; i < N; i++){
        cin >> sunuke[i][0];
        cin >> sunuke[i][1];
        cin >> sunuke[i][2];
    }
    set<int> st;
    for(int i = 0; i < N; i++){
        if(sunuke[i][2] - sunuke[i][0] > 0) st.insert(sunuke[i][1]);
    }
    cout << (st.empty() ? -1 : *st.begin()) << endl;
}
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int solve() {
    int n;
    cin >> n;
    int ans = -1;
    rep(i, 1, n) {
        int a, p, x;
        cin >> a >> p >> x;
        if(a >= x) continue;
        if(ans == -1 || p < ans) {
            ans = p;
        }
    }
    cout << ans << endl;
    return 0;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}
