#include <bits/stdc++.h>
using namespace std;
#define rep(i,t,n) for(int64_t i=t;i<n;i++)
#define Sort(a) sort(a.begin(),a.end())
#define rSort(a,n,m) sort(a.begin()+n-1,a.begin()+m)
#define Reverse(a) reverse(a.begin(),a.end())
#define rReverse(a,n,m) reverse(a.begin()+n-1,a.begin()+m)
#define MOD 1000000007
#define sign(i) -1*pow(-1,i)
#define vi(A,N,i)  vector<int64_t> A(N,i)
#define vs(A,N,i)  vector<string> A(N,i)
#define vb(A,N,i)  vector<bool> A(N,i)
#define INF ((1LL<<62)-(1LL<<31))
//((a+b+c)-max(a,max(b,c))-min(a,min(b,c)))

/*template <class T>

}*/


//cout << fixed << setprecision(桁数);

int64_t def_str(string x,string y){
  int64_t def=0;
  rep(i,0,(int64_t)x.size()){
    if(x[i]!=y[i]){
      def++;
    }
  }
  return def;
}

int main() {
  int64_t a,b,c,d,e,f,ans=0,now_ans=0,mlt_ans=1;
  //double a,b,c,d,e,f,ans=0,now_ans=0,mlt_ans=1;
  string x,y,z;
  char s,t,u;
  bool frag=false,frag1=false,frag2=false;
  vector<int64_t> A{},B{};
  vector<string> C{},D{};
  vector<char> E{},F{};
  vector<bool> G(26,false);
  cin>>a;
  //cin>>x>>y;
  //cin>>s>>t;////////////////////////
  ans=INF;
  rep(i,0,a){
    cin>>b>>c>>d;
    if(b<d){
      ans=min(ans,c);
    }
  }
  if(ans==INF){
    cout<<-1;
    return 0;
  }
  cout<<ans;
}
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(i=0;i<(n);++i)
#define PER(i,n) for(i=(n - 1);i>=0;--i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define lINF 0x3f3f3f3f3f3f3f3f

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
typedef map<int, int> MII;

int main()
{
    int n,i;
    while(cin>>n){
        int a,p,x;
        int res = INF;
        FOR(i,1,n){
            cin>>a>>p>>x;
            if(x>a) res = min(res, p);
        }
        if(res==INF) res=-1;
        cout<<res<<endl;
    }

    return 0;
}
