#include <bits/stdc++.h>
using namespace std;
clock_t __stt;
inline void TStart() { __stt = clock(); }
inline void TReport() {
  cerr << fixed << setprecision(3) << "\nCurrent Case Taken Time : "
       << (double)(clock() - __stt) / CLOCKS_PER_SEC << "sec\n";
}
template <typename T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T ABS(T a) {
  return a > 0 ? a : (-a);
}
template <typename T>
void UMIN(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void UMAX(T &a, T b) {
  if (b > a) a = b;
}
const int U = 1000000001;
struct node {
  node *s[2];
  int dlt;
  void init() {
    dlt = 0;
    s[0] = s[1] = 0;
  }
  void add(int v, int L, int R, int l = 0, int r = U) {
    if (L > R) return;
    if (l >= L && r <= R) {
      dlt += v;
      return;
    }
    int M = (l + r) / 2;
    if (L <= M) {
      if (!s[0]) {
        s[0] = new node;
        s[0]->init();
      }
      s[0]->add(v, L, R, l, M);
    }
    if (R > M) {
      if (!s[1]) {
        s[1] = new node;
        s[1]->init();
      }
      s[1]->add(v, L, R, M + 1, r);
    }
  }
  int qry(int d, int l = 0, int r = U) {
    if (l == r) return dlt;
    int M = (l + r) / 2;
    if (d <= M) return (s[0] ? s[0]->qry(d, l, M) : 0) + dlt;
    return (s[1] ? s[1]->qry(d, M + 1, r) : 0) + dlt;
  }
};
struct data {
  node *lns, *col;
  set<pair<pair<int, int>, pair<int, int> > > *sl, *sc;
  void init() {
    lns = new node;
    lns->init();
    col = new node;
    col->init();
    sl = new set<pair<pair<int, int>, pair<int, int> > >;
    sl->clear();
    sc = new set<pair<pair<int, int>, pair<int, int> > >;
    sc->clear();
  }
  void insL(pair<pair<int, int>, pair<int, int> > A) {
    sl->insert(A);
    sc->insert(make_pair(A.second, A.first));
    lns->add(1, A.first.first, A.first.second);
    col->add(1, A.second.first, A.second.second);
  }
  void insC(pair<pair<int, int>, pair<int, int> > A) {
    insL(make_pair(A.second, A.first));
  }
  void delL(pair<pair<int, int>, pair<int, int> > A) {
    sc->erase(sc->find(make_pair(A.second, A.first)));
    lns->add(-1, A.first.first, A.first.second);
    col->add(-1, A.second.first, A.second.second);
  }
  void delC(pair<pair<int, int>, pair<int, int> > A) {
    sl->erase(sl->find(make_pair(A.second, A.first)));
    lns->add(-1, A.second.first, A.second.second);
    col->add(-1, A.first.first, A.first.second);
  }
} tot;
int n;
void solve(data D) {
  if ((int)(D.sl->size()) <= 2) return;
  set<pair<pair<int, int>, pair<int, int> > >::iterator lf, lb, cf, cb, it;
  lf = D.sl->begin();
  lb = D.sl->end();
  --lb;
  cf = D.sc->begin();
  cb = D.sc->end();
  --cb;
  node *L = D.lns, *C = D.col;
  int d = -1, e = -1, tp = -1;
  while (lf != lb && cf != cb) {
    if (lb != lf) {
      it = lb;
      --it;
      d = lb->first.first - 1;
      tp = 1;
      if (it->first.first - 1 < d && !(L->qry(d))) break;
      --lb;
      d = -1;
    }
    if (lb != lf) {
      ++lf;
      it = lf;
      --it;
      d = lf->first.first - 1;
      tp = 0;
      if (it->first.first - 1 < d && !(L->qry(d))) break;
      d = -1;
    }
    if (cb != cf) {
      it = cb;
      --it;
      e = cb->first.first - 1;
      tp = 3;
      if (it->first.first - 1 < e && !(C->qry(e))) break;
      --cb;
      e = -1;
    }
    if (cb != cf) {
      ++cf;
      it = cf;
      --it;
      e = cf->first.first - 1;
      tp = 2;
      if (it->first.first - 1 < e && !(C->qry(e))) break;
      e = -1;
    }
  }
  if (e == -1 && d == -1) {
    printf("NO\n");
    exit(0);
  }
  data P;
  P.init();
  if (tp == 0) {
    for (it = D.sl->begin(); it != lf; ++it) {
      P.insL(*it);
      D.delL(*it);
    }
    D.sl->erase(D.sl->begin(), lf);
  } else if (tp == 1) {
    for (it = lb; it != D.sl->end(); ++it) {
      P.insL(*it);
      D.delL(*it);
    }
    D.sl->erase(lb, D.sl->end());
  } else if (tp == 2) {
    for (it = D.sc->begin(); it != cf; ++it) {
      P.insC(*it);
      D.delC(*it);
    }
    D.sc->erase(D.sc->begin(), cf);
  } else {
    for (it = cb; it != D.sc->end(); ++it) {
      P.insC(*it);
      D.delC(*it);
    }
    D.sc->erase(cb, D.sc->end());
  }
  solve(D);
  solve(P);
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  tot.init();
  for (i = 0; i < n; ++i) {
    int A, B, C, D;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    ++A;
    ++B;
    --C;
    --D;
    pair<pair<int, int>, pair<int, int> > SL =
        make_pair(make_pair(A, C), make_pair(B, D));
    tot.insL(SL);
  }
  solve(tot);
  printf("YES\n");
  return 0;
}
