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

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<vector<ll>> p(n, vector<ll>(5));
	for (int i = 0; i < n; ++i) {
		cin >> p[i][0];
		cin >> p[i][1];
		cin >> p[i][2];
		cin >> p[i][3];
		cin >> p[i][4];
	}
	ll ok = 1, ng = 1000000001;
	while (ng - ok > 1) {
		ll x = (ng + ok) / 2;
		vector<bool> can(32, false);
		for (int i = 0; i < n; ++i) {
			int bit = 0;
			for (int k = 0; k < 5; ++k) {
				if (p[i][k] >= x) bit |= (1 << k);
			}
			for (int k = 0; k < 32; ++k) {
				if ((bit & k) == k) can[k] = true;
			}
		}
		bool flg = false;
		for (int i = 0; i < n; ++i) {
			for (int j = i+1; j < n; ++j) {
				int bit = 0;
				for (int k = 0; k < 5; ++k) {
					if (p[i][k] >= x || p[j][k] >= x) bit |= (1 << k);
				}
				if (can[31 ^ bit] == true) {
					flg = true;
					break;
				}
			}
			if (flg) break;
		}
		if (flg) ok = x;
		else ng = x;
	}
	cout << ok << endl;
	return 0;
}
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 998244353
using namespace std;

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
ll power(ll x,ll n)
{ll x1=0;
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
       //  if(result>=1000000001) return 0;
        x=(x*x);
      //   if(x>=1000000001) return 0;
        n=n/2;
    }
    return result;
}
int main(){
   IOS;
ll t;t=1;

while(t--){
ll n,s,d;
cin>>n>>s>>d;
ll ans=0;
for(ll i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    if(a<s&&b>d) ans=1;
}
if(ans) cout<<"Yes\n";
else cout<<"No\n";

 
} 
    
    

    
return 0;    
}