#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <iomanip>
#include <ctime>
using namespace std;

template <typename T>
T next_int() {  
	long long x;
	scanf("%lld", &x);
	return x;
/*
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if (ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return x * p;         */
}

const int max_n = (int)2e3 + 227 + 1;
const int max_int = (int)1e9 + 227 + 1;
const int mod = (int)1e9 + 7;

map<int, int> a, b;

int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	int n; cin >> n;

       	for(int i = 0; i < n; i++) {
       		a[next_int<int>()]++;
       		b[next_int<int>()]++;
        }

        if(a.size() == 1 || b.size() == 1) puts("YES"); else puts("NO");                         
}