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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n,vector<int>(3));

    for(int i = 0;i < n;i++){
        for(int j = 0;j < 3;j++){
            cin >> vec.at(i).at(j);
        }
    }
    int minP = -1;
    for(int i = 0;i < n;i++){
        if(vec.at(i).at(2) - vec.at(i).at(0) > 0){
            if(minP == -1)minP = INT_MAX;
            minP = min(minP,vec.at(i).at(1));
        }
    }

    cout << minP;
}




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

#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define PB push_back
#define cauto const auto
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using vi = vector<int>;

struct edge{int to;};
using graph = vector<vector<edge>>;

constexpr auto dbg = false;

int32_t main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vi a(n), p(n), x(n);
  rep(i, 0, n) {
    cin >> a[i] >> p[i] >> x[i];
  }

  
  bool found = false;
  int best = -1;
  rep(i, 0, n) {
    auto feas = x[i] > a[i];
    if (feas) {
      if (!found or p[i] < best) {
	found = true;
	best = p[i];
      }
    }
  }
  cout << best << '\n';
  
}
