#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int l, r, id;
  bool operator<(const node &t) const { return l == t.l ? id < t.id : l < t.l; }
} v[100010][4];
inline bool solve(set<node> l[4]) {
  if (l[0].size() <= 1) return 1;
  set<node> r[4];
  set<node>::iterator it[4];
  int mx[4];
  for (int i = 0; i < 4; i++) {
    it[i] = l[i].begin();
    mx[i] = it[i]->r;
    it[i]++;
  }
  for (; it[0] != l[0].end();) {
    for (int j = 0; j < 4; j++) {
      if (it[j]->l >= mx[j]) {
        for (set<node>::iterator IT = l[j].begin(); IT != it[j];) {
          int id = IT->id;
          IT++;
          for (int k = 0; k < 4; k++)
            r[k].insert(v[id][k]), l[k].erase(v[id][k]);
        }
        return solve(l) && solve(r);
      }
    }
    for (int j = 0; j < 4; j++) {
      mx[j] = max(mx[j], it[j]->r);
      it[j]++;
    }
  }
  return 0;
}
int n;
set<node> st[4];
int main() {
  scanf("%d", &n);
  for (int i = 1, t1, t2, t3, t4; i <= n; i++) {
    scanf("%d%d%d%d", &t1, &t2, &t3, &t4);
    st[0].insert(v[i][0] = (node){t1, t3, i});
    st[1].insert(v[i][1] = (node){-t3, -t1, i});
    st[2].insert(v[i][2] = (node){t2, t4, i});
    st[3].insert(v[i][3] = (node){-t4, -t2, i});
  }
  if (solve(st))
    puts("YES");
  else
    puts("NO");
  return 0;
}
