#include <bits/stdc++.h>
using namespace std;

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

typedef tuple<int32,int32,int32> T;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<T> pax;
  REP(i,n){
    int32 a,p,x;
    cin >> a >> p >> x;
    pax.emplace_back(p,a,x);
  }
  sort(all(pax));
  REP(i,n){
    auto [p,a,x] = pax[i];
    if(x-a > 0){
      ANS(p);
      return 0;
    }
  }
  ANS(-1);
  return 0;
}
#include<bits/stdc++.h>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<set>
#include<cmath>

#define ll long long
#define pb push_back

using namespace std;

int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

int firstDigit(int n)
{
    while (n >= 10)
        n /= 10;
    return n;
}

bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i <= sqrt(num); i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,minv=LONG_MAX,minve=LONG_MAX;
    cin>>n;
    vector <pair<ll,ll>> v = {};
    for(i=0;i<n;i++)
    {
        ll a,p,x,r=0;
        cin>>a>>p>>x;
        r = x-a;
        if(r>0)
        v.pb(make_pair(r,p));
    }
    int l = v.size();
    //cout<<l<<" ";
    for(i=0;i<l;i++)
    {
        minve = min(minve,v[i].second);
    }
    if(l == 0)
        cout<<"-1\n";
    else
        cout<<minve<<"\n";


    return 0;
}
