#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
struct rec {
  int l, r;
  int id;
  bool operator<(rec a) const {
    if (l == a.l) {
      return id < a.id;
    }
    return l < a.l;
  }
} a[maxn][4];
set<rec> s[4];
bool dfs(set<rec> l[4]) {
  if (l[0].size() <= 1) return 1;
  set<rec> r[4];
  int m[4];
  set<rec>::iterator it[4];
  for (int i = 0; i < 4; ++i) {
    it[i] = l[i].begin();
    m[i] = it[i]++->r;
  }
  int se = l[0].size();
  for (int i = 1; i < se; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (it[j]->l >= m[j]) {
        for (auto k = l[j].begin(); k != it[j];) {
          int id = k->id;
          ++k;
          for (int kk = 0; kk < 4; ++kk) {
            r[kk].insert(a[id][kk]);
            l[kk].erase(a[id][kk]);
          }
        }
        return dfs(l) && dfs(r);
      }
      m[j] = max(m[j], it[j]->r);
      it[j]++;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  int n, x1, x2, y1, y2;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    s[0].insert(a[i][0] = {x1, x2, i});
    s[1].insert(a[i][1] = {-x2, -x1, i});
    s[2].insert(a[i][2] = {y1, y2, i});
    s[3].insert(a[i][3] = {-y2, -y1, i});
  }
  if (dfs(s)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
