#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct point {
  int x, y, id;
  inline point(int _x = 0, int _y = 0, int _id = 0) {
    x = _x, y = _y, id = _id;
  }
  inline bool operator<(const point &p) const {
    if (x != p.x)
      return x < p.x;
    else if (y != p.y)
      return y < p.y;
    else
      return id < p.id;
  }
} p[N][4];
inline bool solve(set<point> a[4]) {
  int size = a[0].size(), r[4] = {(int)-1e9, (int)-1e9, (int)-1e9, (int)-1e9};
  if (size <= 1) return 1;
  set<point>::iterator t[4];
  for (int i = 0; i < 4; i++) t[i] = a[i].begin();
  for (int i = 1; i < size; i++)
    for (int j = 0; j < 4; j++) {
      r[j] = max(r[j], t[j]->y);
      t[j]++;
      if (t[j]->x >= r[j]) {
        set<point> b[4];
        for (auto tt = a[j].begin(); tt != t[j];) {
          point *tmp = p[tt->id];
          tt++;
          for (int k = 0; k < 4; k++) {
            a[k].erase(tmp[k]);
            b[k].insert(tmp[k]);
          }
        }
        return solve(b) && solve(a);
      }
    }
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  set<point> a[4];
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    p[i][0] = point(x1, x2, i);
    a[0].insert(p[i][0]);
    p[i][1] = point(-x2, -x1, i);
    a[1].insert(p[i][1]);
    p[i][2] = point(y1, y2, i);
    a[2].insert(p[i][2]);
    p[i][3] = point(-y2, -y1, i);
    a[3].insert(p[i][3]);
  }
  puts(solve(a) ? "YES" : "NO");
  return 0;
}
