#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;

    int min = 1000000000 + 1;
    for(int i = 0; i < N; i++) {
        int A, P, X;
        cin >> A >> P >> X;
        if((X-A) > 0) {
            if(P < min) {
                min = P;
            }
        }
    }

    if(min == (1000000000+1)) {
        cout << -1 << endl;
    } else {
        cout << min << endl;
    }

    return 0;
}
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main()
{
	unsigned int n;
	vector<long> a, p, x;
	unsigned int i;
	long t;
	long ans = -1;

	// input
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> t;
		a.push_back(t);
		cin >> t;
		p.push_back(t);
		cin >> t;
		x.push_back(t);
	}

	// calc
	for (i = 0; i < n; i++) {
		if ((-1 == ans) || (ans > p[i])) {
			if (a[i] < x[i]) {
				ans = p[i];
			}
		}
	}

	// output
	cout << ans << endl;

	return 0;
}