#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <time.h>
#include <set>
using namespace std;

int64_t mod = 998244353 ;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}
/*
int getnum(vector<int> &array, vector<char> &c, char a){
    for (int i = 0; i < c.size(); i++)
    {
        if (a == c.at(i))
        {
            return array.at(i) ;
        }
        
    }
    
}

int64_t repeatmod(int64_t n, int64_t pow, int64_t p){
    if (pow == 1)
    {
        return n%p ;
    }
    
    if (pow % 2)
    {
        return (repeatmod(n, pow-1,p) * n) % p ;
    }else
    {
        return (repeatmod(n,pow/2,p) * repeatmod(n,pow/2,p)) % p ;
    }
    
    
}
*/
int prod(pair<int,int> a,pair<int,int> b){
    return a.first * b.first + a.second * b.second ;
}

int main(){
    int n ;
    cin >> n ;
    if (n == 1)
    {
        cout << "Yes" << endl ;
        return 0 ;
    }
    
    vector<pair<int,int> > s(n) ;
    vector<pair<int,int> > t(n) ;
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i).first >> s.at(i).second ;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> t.at(i).first >> t.at(i).second ;
    }
    int a0 = s.at(0).first ;
    int b0 = s.at(0).second ;
    for (int i = 0; i < n; i++)
    {
        s.at(i).first -= a0 ;
        s.at(i).second -= b0 ;
    }
    pair<int,int> kitei1 = make_pair(s.at(1).first,s.at(1).second) ;
    pair<int,int> kitei2 = make_pair(-s.at(1).second,s.at(1).first) ;
    set <pair<pair<int,int>,pair<int,int> > > svec ;
    for (int i = 0; i < n; i++)
    {
        int size = prod(s.at(i),s.at(i)) ;
        svec.insert(make_pair(make_pair(size*size,prod(s.at(i),kitei1)),make_pair(size*size,prod(s.at(i),kitei2)))) ;
    }
    for (int onum = 0; onum < n; onum++)
    {
        vector<pair<int,int> > copy = t ;
        int c0 = copy.at(onum).first ;
        int d0 = copy.at(onum).second ;
        for (int i = 0; i < n; i++)
        {
            copy.at(i).first -= c0 ;
            copy.at(i).second -= d0 ;
        }
        for (int knum = 0; knum < n; knum++)
        {
            pair<int,int> kitei11 = make_pair(copy.at(knum).first,copy.at(knum).second) ;
            pair<int,int> kitei22 = make_pair(-copy.at(knum).second,copy.at(knum).first) ;
            set <pair<pair<int,int>,pair<int,int> > > tvec ;
            for (int i = 0; i < n; i++)
            {
                int size = prod(copy.at(i),copy.at(i)) ;
                tvec.insert(make_pair(make_pair(size*size,prod(copy.at(i),kitei11)),make_pair(size*size,prod(copy.at(i),kitei22)))) ;
            }
            if ( svec == tvec)
            {
                cout << "Yes" << endl ;
                return 0 ;
            }
            
        }
    
    
    }
    cout << "No" << endl ;

}
#include <bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long
#define ui unsigned int
#define us unsigned short
#define inf_int 1e9
#define inf_ll 1e18
#define mod 1000000007
#define smod 998244353

vector<pair<ll, ll>> v[5];

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	
	int n;
	cin >> n;
	
	vector<pair<ll, ll>> v[5];
	ll data[n][5];
	for(int x=0;x<n;x++){
		for(int y=0;y<5;y++){
			cin >> data[x][y];
			v[y].push_back({data[x][y], x});
		}
	}
	
	for(int x=0;x<5;x++){
		sort(v[x].begin(), v[x].end());
	}
	ll ans = 0;
	for(int x=0;x<n;x++){
		for(int y=x+1;y<n;y++){
			vector<pair<ll, ll>> tmp;
			for(int z=0;z<5;z++){
				tmp.push_back({max(data[x][z], data[y][z]), z});
			}
			
			sort(tmp.begin(), tmp.end());
						
			for(int i=1;i<=3;i++){
				int idx = v[tmp[0].second][n-i].second;
				if(idx == x || idx == y) continue;
				
				tmp[0].first = max(tmp[0].first, v[tmp[0].second][n-i].first);
				break;
			}
			
			ll mn = inf_ll;
			for(int z=0;z<5;z++) mn = min(mn, tmp[z].first);
			ans = max(ans, mn);
		}
	}
	cout << ans << "\n";
    return 0;
}

// Santai
// Pikirin dengan benar-benar