#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int n;
    cin >> n;
    int vert = -100;
    int hor = -100;
    bool f1 = 1, f2 = 1;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        if (i == 0)
            vert = x, hor = y;
        else {
            if (vert != x)
                f1 = 0;
            if (hor != y)
                f2 = 0;
        }
    }
    if (f1 | f2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}