#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n;
struct Range {
  int l, r, id;
  friend bool operator<(const Range &a, const Range &b) {
    return a.l == b.l ? (a.r == b.r ? a.id < b.id : a.r < b.r) : a.l < b.l;
  }
} a[100010][4];
set<Range> S[4];
bool Solve(set<Range> *S) {
  if ((int)S[0].size() == 1) return true;
  set<Range>::iterator it[4];
  int mx[4] = {-inf, -inf, -inf, -inf};
  for (int i = 0; i < 4; ++i) it[i] = S[i].begin();
  for (int i = 1; i < (int)S[0].size(); ++i) {
    for (int j = 0; j < 4; ++j) mx[j] = max(mx[j], it[j]->r), ++it[j];
    for (int j = 0; j < 4; ++j) {
      if ((it[j]->l) >= mx[j]) {
        auto z = S[j].begin();
        set<Range> T[4];
        for (int k = 0; k < i; ++k) {
          int id = (z->id);
          ++z;
          for (int p = 0; p < 4; ++p) {
            T[p].insert(a[id][p]);
            S[p].erase(a[id][p]);
          }
        }
        return Solve(T) && Solve(S);
      }
    }
  }
  return false;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    int x1 = read(), ysgh = read(), x2 = read(), y2 = read();
    a[i][0] = {x1, x2, i};
    a[i][1] = {ysgh, y2, i};
    a[i][2] = {-x2, -x1, i};
    a[i][3] = {-y2, -ysgh, i};
    for (int j = 0; j < 4; ++j) {
      S[j].insert(a[i][j]);
    }
  }
  printf(Solve(S) ? "YES\n" : "NO\n");
  return 0;
}
