#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair



int main(){
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++) cin >> v[i].F >> v[i].S;
    bool f1 = true;
    bool f2 = true;
    for (int i = 1; i < n; i++) if (v[i - 1].F != v[i].F) f1 = false;
    for (int i = 1; i < n; i++) if (v[i - 1].S != v[i].S) f2 = false;
    if (f1 || f2) cout << "YES";
    else cout << "NO";
    return 0;
}