#include <bits/stdc++.h>
using namespace std;
char IO;
int rd() {
  int s = 0, f = 0;
  while (IO = getchar(), IO < '0' || IO > '9')
    if (IO == '-') f = 1;
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (IO = getchar(), IO >= '0' && IO <= '9');
  return f ? -s : s;
}
const int N = 1e5 + 10;
int n;
struct Rec {
  int a, b, c, d;
  void Get() { a = rd(), b = rd(), c = rd(), d = rd(); }
} A[N];
struct node {
  int a, b, id;
  void Get(Rec x, int k, int i) {
    if (k == 0)
      a = x.a, b = x.c;
    else if (k == 1)
      a = -x.c, b = -x.a;
    else if (k == 2)
      a = x.b, b = x.d;
    else if (k == 3)
      a = -x.d, b = -x.b;
    id = i;
  }
  bool operator<(const node __) const {
    if (a ^ __.a) return a < __.a;
    return id < __.id;
  }
};
node s[N][4];
const int INF = 1e9;
bool dfs(set<node> st[4]) {
  if (st[0].size() <= 1) return true;
  set<node>::iterator it[4], t;
  for (int i = 0, iend = 3; i <= iend; ++i) it[i] = st[i].begin();
  set<node> S[4];
  for (int i = 0, iend = 3; i <= iend; ++i) S[i].clear();
  int ma[4] = {-INF, -INF, -INF, -INF};
  for (int o = 1, oend = st[0].size() - 1; o <= oend; ++o) {
    for (int i = 0, iend = 3; i <= iend; ++i) {
      ma[i] = max(ma[i], it[i]->b);
      it[i]++;
      if (it[i]->a >= ma[i]) {
        for (t = st[i].begin(); t != it[i];) {
          int id = t->id;
          t++;
          for (int j = 0, jend = 3; j <= jend; ++j) {
            S[j].insert(s[id][j]);
            st[j].erase(s[id][j]);
          }
        }
        return dfs(st) && dfs(S);
      }
    }
  }
  return false;
}
set<node> st[4];
int main() {
  n = rd();
  for (int i = 1, iend = n; i <= iend; ++i) A[i].Get();
  for (int i = 1, iend = n; i <= iend; ++i)
    for (int j = 0, jend = 3; j <= jend; ++j) {
      s[i][j].Get(A[i], j, i);
      st[j].insert(s[i][j]);
    }
  int ans = dfs(st);
  puts(ans ? "YES" : "NO");
}
