#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
};
struct node {
  int idx;
  int next;
  node(int idx = 0, int next = 0) : idx(idx), next(next) {}
};
vector<rect> r;
bool cmp_left(int a, int b) { return r[a].x1 < r[b].x1; }
bool cmp_right(int a, int b) { return r[a].x2 > r[b].x2; }
bool cmp_top(int a, int b) { return r[a].y1 < r[b].y1; }
bool cmp_bottom(int a, int b) { return r[a].y2 > r[b].y2; }
bool split(vector<node> &L, vector<node> &R, vector<node> &T, vector<node> &B,
           vector<int> &deleted) {
  if (L.size() == 2) return true;
  for (int i = 1; i < L.size(); ++i) deleted[L[i].idx] = 0;
  for (int i = 0; i < L.size(); ++i) L[i].next = i + 1;
  for (int i = 0; i < R.size(); ++i) R[i].next = i + 1;
  for (int i = 0; i < T.size(); ++i) T[i].next = i + 1;
  for (int i = 0; i < B.size(); ++i) B[i].next = i + 1;
  vector<vector<node>> cts(1);
  int cnt = L.size() - 1;
  while (true) {
    if (cnt == 1) break;
    int lp, rp, tp, bp;
    int li, ri, ti, bi;
    lp = rp = tp = bp = 0;
    for (li = L[0].next; deleted[L[li].idx]; li = L[li].next)
      cts[deleted[L[li].idx] + 0].push_back(node(L[li].idx));
    for (ri = R[0].next; deleted[R[ri].idx]; ri = R[ri].next)
      cts[deleted[R[ri].idx] + 1].push_back(node(R[ri].idx));
    for (ti = T[0].next; deleted[T[ti].idx]; ti = T[ti].next)
      cts[deleted[T[ti].idx] + 2].push_back(node(T[ti].idx));
    for (bi = B[0].next; deleted[B[bi].idx]; bi = B[bi].next)
      cts[deleted[B[bi].idx] + 3].push_back(node(B[bi].idx));
    L[lp].next = li;
    R[rp].next = ri;
    T[tp].next = ti;
    B[bp].next = bi;
    int lm, rm, tm, bm;
    lm = tm = -1;
    rm = bm = int(2e9);
    vector<node> *sp = NULL;
    int spl;
    for (int i = 1; i < cnt; ++i) {
      lp = li;
      rp = ri;
      tp = ti;
      bp = bi;
      lm = max(lm, r[L[lp].idx].x2);
      rm = min(rm, r[R[rp].idx].x1);
      tm = max(tm, r[T[tp].idx].y2);
      bm = min(bm, r[B[bp].idx].y1);
      for (li = L[li].next; deleted[L[li].idx]; li = L[li].next)
        cts[deleted[L[li].idx] + 0].push_back(node(L[li].idx));
      for (ri = R[ri].next; deleted[R[ri].idx]; ri = R[ri].next)
        cts[deleted[R[ri].idx] + 1].push_back(node(R[ri].idx));
      for (ti = T[ti].next; deleted[T[ti].idx]; ti = T[ti].next)
        cts[deleted[T[ti].idx] + 2].push_back(node(T[ti].idx));
      for (bi = B[bi].next; deleted[B[bi].idx]; bi = B[bi].next)
        cts[deleted[B[bi].idx] + 3].push_back(node(B[bi].idx));
      L[lp].next = li;
      R[rp].next = ri;
      T[tp].next = ti;
      B[bp].next = bi;
      if (lm <= r[L[li].idx].x1) {
        sp = &L;
        spl = li;
        break;
      }
      if (rm >= r[R[ri].idx].x2) {
        sp = &R;
        spl = ri;
        break;
      }
      if (tm <= r[T[ti].idx].y1) {
        sp = &T;
        spl = ti;
        break;
      }
      if (bm >= r[B[bi].idx].y2) {
        sp = &B;
        spl = bi;
        break;
      }
    }
    if (!sp) return false;
    int cc = 0;
    for (int x = (*sp)[0].next; x < spl; x = (*sp)[x].next) {
      int vv = (*sp)[x].idx;
      deleted[vv] = cts.size();
      cnt -= 1;
      cc += 1;
    }
    cts.resize(cts.size() + 4);
    for (int x = cts.size() - 4; x < cts.size(); ++x) {
      cts[x].reserve(cc + 1);
      cts[x].resize(1);
    }
  }
  for (int li = L[0].next; li < L.size(); li = L[li].next)
    if (deleted[L[li].idx])
      cts[deleted[L[li].idx] + 0].push_back(node(L[li].idx));
  for (int ri = R[0].next; ri < R.size(); ri = R[ri].next)
    if (deleted[R[ri].idx])
      cts[deleted[R[ri].idx] + 1].push_back(node(R[ri].idx));
  for (int ti = T[0].next; ti < T.size(); ti = T[ti].next)
    if (deleted[T[ti].idx])
      cts[deleted[T[ti].idx] + 2].push_back(node(T[ti].idx));
  for (int bi = B[0].next; bi < B.size(); bi = B[bi].next)
    if (deleted[B[bi].idx])
      cts[deleted[B[bi].idx] + 3].push_back(node(B[bi].idx));
  for (int i = 1; i < cts.size(); i += 4)
    if (!split(cts[i], cts[i + 1], cts[i + 2], cts[i + 3], deleted))
      return false;
  return true;
}
void solve() {
  int n;
  scanf("%d", &n);
  r.resize(n);
  for (int i = 0; i < n; ++i)
    scanf("%d%d%d%d", &r[i].x1, &r[i].y1, &r[i].x2, &r[i].y2);
  vector<int> deleted(n, 0);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) v[i] = i;
  vector<int> left = v;
  vector<int> right = v;
  vector<int> top = v;
  vector<int> bottom = v;
  sort(left.begin(), left.end(), cmp_left);
  sort(right.begin(), right.end(), cmp_right);
  sort(top.begin(), top.end(), cmp_top);
  sort(bottom.begin(), bottom.end(), cmp_bottom);
  vector<node> L(n + 1), R(n + 1), T(n + 1), B(n + 1);
  for (int i = 1; i <= n; ++i) {
    L[i].idx = left[i - 1];
    R[i].idx = right[i - 1];
    T[i].idx = top[i - 1];
    B[i].idx = bottom[i - 1];
  }
  if (split(L, R, T, B, deleted))
    printf("YES");
  else
    printf("NO");
}
int main() {
  solve();
  return 0;
}
