#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0)
typedef long long ll;
const int N = 1e5 + 4 , MOD = 1e9 + 7 ;
int n , a[N] , p[N] , x[N] , mn ;
int solve(int idx)
{
if(idx == n + 1)
return mn ;
if(a[idx] < x[idx])
mn = min (mn , p[idx]) ;
solve(idx + 1) ;
return mn ;
}
int main() {
IO ;
mn = INT32_MAX ;
cin>>n ;
for(int i=1 ; i <= n ; i++)
cin>>a[i]>>p[i]>>x[i] ;
if(solve(1) == INT32_MAX)
cout<<-1<<'\n' ;
else
cout<<solve(1) ;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBJTyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApLCBjaW4udGllKDApLGNvdXQudGllKDApCnR5cGVkZWYgbG9uZyBsb25nIGxsOwpjb25zdCBpbnQgTiA9IDFlNSArIDQgLCBNT0QgPSAxZTkgKyA3IDsKaW50IG4gLCBhW05dICwgcFtOXSAsIHhbTl0gLCBtbiA7CmludCBzb2x2ZShpbnQgaWR4KQp7CiAgICBpZihpZHggPT0gbiArIDEpCiAgICAgICAgcmV0dXJuIG1uIDsKICAgIGlmKGFbaWR4XSA8IHhbaWR4XSkKICAgICAgICBtbiA9IG1pbiAobW4gLCBwW2lkeF0pIDsKICAgIHNvbHZlKGlkeCArIDEpIDsKICAgIHJldHVybiBtbiA7Cn0KaW50IG1haW4oKSB7CiAgICBJTyA7CiAgICBtbiA9IElOVDMyX01BWCA7CiAgICBjaW4+Pm4gOwogICAgZm9yKGludCBpPTEgOyBpIDw9IG4gOyBpKyspCiAgICAgICAgY2luPj5hW2ldPj5wW2ldPj54W2ldIDsKICAgIGlmKHNvbHZlKDEpID09IElOVDMyX01BWCkKICAgICAgICBjb3V0PDwtMTw8J1xuJyA7CiAgICBlbHNlCiAgICAgICAgY291dDw8c29sdmUoMSkgOwogICAgcmV0dXJuIDA7Cn0=