#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int ans = 1001001001;
  rep(i,n) {
    int a, b, x;
    cin >> a >> b >> x;
    int cnt = x - a;
    if (cnt > 0) ans = min(ans, b);
  }
  if (ans == 1001001001) ans = -1;
  cout << ans << endl;
  return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>
#include <map>
using namespace std;

using ll = long long;

int main()
{
  int N;
  cin >> N;
  vector<pair<ll, ll>> vec(N);
  for (int i = 0; i < N; ++i)
  {
    ll a, p, x;
    cin >> a >> p >> x;
    vec[i] = pair<ll, ll>(p, x - a);
  }

  sort(vec.begin(), vec.end());

  ll res = -1;
  for (int i = 0; i < N; ++i)
  {
    auto p = vec[i];
    // cout << p.first << endl;
    if (p.second > 0)
    {
      res = p.first;
      break;
    }
  }

  cout << res << endl;
}
