#include <bits/stdc++.h>
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define REPS(i, ss, nn ) for(int i = ss ; i < (int) nn; i++)
#define REV(i, ss, nn ) for(int i = ss ; i >= nn; i--)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace std{
    template<class Fun>
    class y_combinator_result{
        Fun fun_;
        public:
            template<class T>
            explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)){}
            template<class ...Args>
            decltype(auto) operator()(Args&&...args){
                return fun_(std::ref(*this), std::forward<Args>(args)...);
            }
    };
    template<class Fun>
    decltype(auto) y_combinator(Fun && fun){
        return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
    }
};
template<typename T>
bool umax(T& a, T b){
    bool ret = a < b;
    if(ret) a = b;
    return ret;
}
template<typename T>
bool umin(T& a, T b){
    bool ret = a > b;
    if(ret) a = b;
    return ret;
}
struct edge{
    int to; ll cost;
    int from;
    edge(){ edge(0,0);}
    edge(int to_, ll cost_) : to(to_), cost(cost_){}
    edge(int to_, int from_, ll cost_) : to(to_), cost(cost_), from(from_){}
};

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}

template<typename... T>
void write(T... a){
    ((cout << a),...);
}


template<typename T>
vector<T> read_array(int sz){
    vector<T> ret(sz);
    for(auto & x : ret) cin >> x;
    return ret;
}

void solve(){
    int n;
    read(n);
    ll ans = 2e9;
    REP(i, n){
        ll a, p, x;
        read(a, p, x);
        if(a < x){
            umin(ans, p);
        }
    }
    if(ans > (ll) 1e9) ans = -1;
    write(ans,"\n");
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    int T = 1;
    // cin >> T;
    while(T--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main( )
{
    ll n,a,b,c;
    cin>>n;
    ll ans = INT_MAX,cnt=0;
    while(n--)
    {
        cin>>a>>b>>c;
        if(c-a > 0){ans=min(ans,b);++cnt;}
    }
    if(cnt)cout<<ans<<endl;
    else cout<<-1<<endl;
}
