#include <bits/stdc++.h>
struct rect {
  int x1, y1, x2, y2;
  bool done;
};
bool cmpRectX1(const rect *r1, const rect *r2) { return r1->x1 < r2->x1; }
bool cmpRectX2(const rect *r1, const rect *r2) { return r1->x2 > r2->x2; }
bool cmpRectY1(const rect *r1, const rect *r2) { return r1->y1 < r2->y1; }
bool cmpRectY2(const rect *r1, const rect *r2) { return r1->y2 > r2->y2; }
int n;
rect rec[100005];
bool solve(std::vector<rect *> rects);
bool split(std::vector<rect *>::iterator begin,
           std::vector<rect *>::iterator end, int &totLeft) {
  std::vector<rect *> r;
  for (auto it = begin; it != end; it++) {
    if (!(*it)->done) {
      r.push_back(*it);
    }
  }
  bool success = solve(r);
  for (auto v : r) {
    v->done = true;
    totLeft--;
  }
  return success;
}
rect *nextRect(std::vector<rect *> r, int &pos) {
  while (r[pos]->done) pos++;
  return r[pos];
}
bool solve(std::vector<rect *> rects) {
  std::vector<rect *> rx1 = rects, ry1 = rects;
  std::vector<rect *> rx2 = rects, ry2 = rects;
  std::sort(rx1.begin(), rx1.end(), cmpRectX1);
  std::sort(rx2.begin(), rx2.end(), cmpRectX2);
  std::sort(ry1.begin(), ry1.end(), cmpRectY1);
  std::sort(ry2.begin(), ry2.end(), cmpRectY2);
  int nxi1 = 0, nxi2 = 0;
  int nyi1 = 0, nyi2 = 0;
  bool found;
  int totLeft = rects.size();
  do {
    nextRect(rx1, nxi1);
    nextRect(rx2, nxi2);
    nextRect(ry1, nyi1);
    nextRect(ry2, nyi2);
    if (totLeft == 1) return true;
    found = false;
    int xi1 = nxi1, xi2 = nxi2;
    int yi1 = nyi1, yi2 = nyi2;
    int xv1 = rx1[xi1]->x2;
    int xv2 = rx2[xi2]->x1;
    int yv1 = ry1[yi1]->y2;
    int yv2 = ry2[yi2]->y1;
    int doneX = 0;
    int doneY = 0;
    while (doneX < totLeft - 1 || doneY < totLeft - 1) {
      rect *r;
      if (doneX < totLeft - 1) {
        r = nextRect(rx1, ++xi1);
        if (r->x1 >= xv1) {
          if (!split(rx1.begin() + nxi1, rx1.begin() + xi1, totLeft))
            return false;
          nxi1 = xi1;
          found = true;
          break;
        }
        xv1 = std::max(xv1, r->x2);
        doneX++;
        r = nextRect(rx2, ++xi2);
        if (r->x2 <= xv2) {
          if (!split(rx2.begin() + nxi2, rx2.begin() + xi2, totLeft))
            return false;
          nxi2 = xi2;
          found = true;
          break;
        }
        xv2 = std::min(xv2, r->x1);
        doneX++;
      }
      if (doneY < totLeft - 1) {
        rect *r = nextRect(ry1, ++yi1);
        if (r->y1 >= yv1) {
          if (!split(ry1.begin() + nyi1, ry1.begin() + yi1, totLeft))
            return false;
          nyi1 = yi1;
          found = true;
          break;
        }
        yv1 = std::max(yv1, r->y2);
        doneY++;
        r = nextRect(ry2, ++yi2);
        if (r->y2 <= yv2) {
          if (!split(ry2.begin() + nyi2, ry2.begin() + yi2, totLeft))
            return false;
          nyi2 = yi2;
          found = true;
          break;
        }
        yv2 = std::min(yv2, r->y1);
        doneY++;
      }
    }
  } while (found);
  return false;
}
void run() {
  std::vector<rect *> rects;
  scanf("%d", &n);
  int area = 0;
  for (int i = 0; i < n; i++) {
    rect &r = rec[i];
    scanf("%d %d %d %d", &r.x1, &r.y1, &r.x2, &r.y2);
    r.done = false;
    rects.push_back(&r);
    area += (r.x2 - r.x1) * (r.y2 - r.y1);
  }
  printf("%s\n", solve(rects) ? "YES" : "NO");
}
int main() {
  run();
  return 0;
}
