#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a) for(int i = 0; i < (int) a; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	int n; cin >> n;
	int ans = 1e9+7;

	FOR(i, n){
		int a, b, c; cin >> a >> b >> c;

		if(c > a) ans = min(ans, b);
	}

	if(ans == 1e9+7) cout << "-1\n";
	else cout << ans << '\n';

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;

const ll mod = 10;

int main(){
  int n;
  cin >> n;
  vector<tuple<int,int,int>> pax(n);
  for(int i = 0; i < n; i++){
    int a, p, x;
    cin >> a >> p >> x;
    pax[i] = make_tuple(p,a,x);
  }
  sort(pax.begin(),pax.end());
  for(int i = 0; i < n; i++){
    if(get<1>(pax[i])<get<2>(pax[i])){
      cout << get<0>(pax[i]) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
