#include <bits/stdc++.h>
using namespace std;
void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
template <typename T>
void umin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void umax(T &a, T b) {
  a = max(a, b);
}
struct S {
  int l, r;
  int d, u;
};
struct Node {
  int pre, nxt;
};
void lnk(Node lst[], int x, int y) {
  lst[x].nxt = y;
  lst[y].pre = x;
}
void del(Node lst[], int x, int &h) {
  int pre = lst[x].pre, nxt = lst[x].nxt;
  if (pre >= 0)
    lst[pre].nxt = nxt;
  else
    h = nxt;
  if (nxt >= 0) lst[nxt].pre = pre;
  if (x == h) h = lst[h].nxt;
}
void pri(const Node lst[], int x) {
  while (x >= 0) {
    cerr << ' ' << x;
    x = lst[x].nxt;
  }
}
int lsz(const Node lst[], int x) {
  int res = 0;
  while (x >= 0) {
    ++res;
    x = lst[x].nxt;
  }
  return res;
}
Node llist[100016], rlist[100016], dlist[100016], ulist[100016];
int ids[100016];
S s[100016];
bool cmpl(int a, int b) { return s[a].l < s[b].l; }
bool cmpr(int a, int b) { return s[a].r > s[b].r; }
bool cmpd(int a, int b) { return s[a].d < s[b].d; }
bool cmpu(int a, int b) { return s[a].u > s[b].u; }
int init(int n, Node lst[]) {
  lst[ids[0]].pre = -1;
  for (int i = 1; i < n; ++i) lnk(lst, ids[i - 1], ids[i]);
  lst[ids[n - 1]].nxt = -1;
  return ids[0];
}
void del_all(int x, int &hl, int &hr, int &hd, int &hu) {
  del(llist, x, hl);
  del(rlist, x, hr);
  del(dlist, x, hd);
  del(ulist, x, hu);
}
void init_all(int n, int &hl, int &hr, int &hd, int &hu) {
  sort(ids, ids + n, cmpl);
  hl = init(n, llist);
  sort(ids, ids + n, cmpr);
  hr = init(n, rlist);
  sort(ids, ids + n, cmpd);
  hd = init(n, dlist);
  sort(ids, ids + n, cmpu);
  hu = init(n, ulist);
}
bool check(int n, int hl, int hr, int hd, int hu) {
  if (n < 4) return true;
  int xl = hl, xr = hr, xd = hd, xu = hu;
  int gl, gr, gd, gu;
  int llo = 1234567890, rhi = 0;
  int dlo = 1234567890, uhi = 0;
  for (int i = 1; i <= n / 2; ++i) {
    int yl = llist[xl].nxt;
    umax(rhi, s[xl].r);
    if (rhi <= s[yl].l) {
      for (int j = 0, v = hl; j < i; ++j, v = llist[v].nxt) {
        del_all(v, hl, hr, hd, hu);
        ids[j] = v;
      }
      init_all(i, gl, gr, gd, gu);
      return check(i, gl, gr, gd, gu) && check(n - i, hl, hr, hd, hu);
    }
    xl = yl;
    int yd = dlist[xd].nxt;
    umax(uhi, s[xd].u);
    if (uhi <= s[yd].d) {
      for (int j = 0, v = hd; j < i; ++j, v = dlist[v].nxt) {
        del_all(v, hl, hr, hd, hu);
        ids[j] = v;
      }
      init_all(i, gl, gr, gd, gu);
      return check(i, gl, gr, gd, gu) && check(n - i, hl, hr, hd, hu);
    }
    xd = yd;
    int yr = rlist[xr].nxt;
    umin(llo, s[xr].l);
    if (llo >= s[yr].r) {
      for (int j = 0, v = hr; j < i; ++j, v = rlist[v].nxt) {
        del_all(v, hl, hr, hd, hu);
        ids[j] = v;
      }
      init_all(i, gl, gr, gd, gu);
      return check(i, gl, gr, gd, gu) && check(n - i, hl, hr, hd, hu);
    }
    xr = yr;
    int yu = ulist[xu].nxt;
    umin(dlo, s[xu].d);
    if (dlo >= s[yu].u) {
      for (int j = 0, v = hu; j < i; ++j, v = ulist[v].nxt) {
        del_all(v, hl, hr, hd, hu);
        ids[j] = v;
      }
      init_all(i, gl, gr, gd, gu);
      return check(i, gl, gr, gd, gu) && check(n - i, hl, hr, hd, hu);
    }
    xu = yu;
  }
  return false;
}
int main() {
  int n;
  int hl, hr, hd, hu;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i].l >> s[i].d >> s[i].r >> s[i].u;
  iota(ids, ids + n, 0);
  init_all(n, hl, hr, hd, hu);
  cout << (check(n, hl, hr, hd, hu) ? "YES\n" : "NO\n");
  return 0;
}
