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

const int INF = 1001001001;

int main()
{
	int ans = INF;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a, p, x;
		cin >> a >> p >> x;
		if(a < x) ans = min(ans, p);
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define mem(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << #x << " = " << x << endl
#define fi(i, l, r) for (int i = l; i < r; i++)
#define cd(a) scanf("%d", &a)
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    bool ifCan = false; 
    int m = 1e9 + 1;
    while (N--)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        if (a < c) 
        {
            ifCan = true; 
            m = min(m, b); 
        }
    }
    if (ifCan)
        printf("%d\n", m);
    else
        printf("-1\n");
    return 0;
}
