#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> aa, bb;
    for(int a0 = 0; a0 < n; a0++){
        int x;
        int y;
        cin >> x >> y;
        aa.push_back(x);
        bb.push_back(y);
    }
    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());
    aa.resize(unique(aa.begin(), aa.end()) - aa.begin());
    bb.resize(unique(bb.begin(), bb.end()) - bb.begin());
    if (aa.size() == 1 || bb.size() == 1)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}