#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
struct node {
  int sa, ea, sb, eb;
} a[N];
int t[N << 1], rt1[N << 1], rt2[N << 1], lc[N * 80], rc[N * 80], tot, n, m1, m2;
bool cnt[N * 80], addv[N * 80];
inline bool cmp1(const node &a, const node &b) { return a.ea < b.ea; }
inline bool cmp2(const node &a, const node &b) { return a.sa < b.sa; }
int add(int pre, int L, int R, int x, int y) {
  if (addv[pre]) return pre;
  int o = ++tot;
  cnt[o] = 1;
  if (x <= L && y >= R) {
    addv[o] = 1;
    lc[o] = lc[pre];
    rc[o] = rc[pre];
  } else {
    int M = L + R >> 1;
    addv[o] = 0;
    if (x <= M)
      lc[o] = add(lc[pre], L, M, x, y);
    else
      lc[o] = lc[pre];
    if (y > M)
      rc[o] = add(rc[pre], M + 1, R, x, y);
    else
      rc[o] = rc[pre];
  }
  return o;
}
bool ask(int o, int L, int R, int x, int y) {
  if (addv[o]) return 0;
  if (x <= L && y >= R) return !cnt[o];
  int M = L + R >> 1;
  return (x > M || ask(lc[o], L, M, x, y)) &&
         (y <= M || ask(rc[o], M + 1, R, x, y));
}
inline bool check() {
  int i, k = 1;
  memset(rt1, 0, sizeof(rt1));
  memset(rt2, 0, sizeof(rt2));
  tot = 0;
  sort(a + 1, a + n + 1, cmp1);
  for (i = 1; i <= (m1); ++i) {
    rt1[i] = rt1[i - 1];
    for (; k <= n && a[k].ea == i; ++k)
      rt1[i] = add(rt1[i], 1, m2, a[k].sb, a[k].eb);
  }
  sort(a + 1, a + n + 1, cmp2);
  k = n;
  for (i = m1; i >= (1); --i) {
    rt2[i] = rt2[i + 1];
    for (; k && a[k].sa == i; --k)
      rt2[i] = add(rt2[i], 1, m2, a[k].sb, a[k].eb);
  }
  for (i = 1; i <= (n); ++i)
    if (!ask(rt1[a[i].sa - 1], 1, m2, a[i].sb, a[i].eb) ||
        !ask(rt2[a[i].ea + 1], 1, m2, a[i].sb, a[i].eb)) {
      puts("NO");
      return 0;
    }
  return 1;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= (n); ++i) {
    scanf("%d%d%d%d", &a[i].sa, &a[i].ea, &a[i].sb, &a[i].eb);
    t[(i << 1) - 1] = a[i].sa;
    t[i << 1] = a[i].ea;
  }
  sort(t + 1, t + (n << 1) + 1);
  m1 = unique(t + 1, t + (n << 1) + 1) - t - 1;
  for (i = 1; i <= (n); ++i) {
    a[i].sa = lower_bound(t + 1, t + m1 + 1, a[i].sa) - t;
    a[i].ea = lower_bound(t + 1, t + m1 + 1, a[i].ea) - t;
  }
  for (i = 1; i <= (n); ++i) {
    t[(i << 1) - 1] = a[i].sb;
    t[i << 1] = a[i].eb;
  }
  sort(t + 1, t + (n << 1) + 1);
  m2 = unique(t + 1, t + (n << 1) + 1) - t - 1;
  for (i = 1; i <= (n); ++i) {
    a[i].sb = lower_bound(t + 1, t + m2 + 1, a[i].sb) - t;
    a[i].eb = lower_bound(t + 1, t + m2 + 1, a[i].eb) - t;
  }
  if (!check()) return 0;
  for (i = 1; i <= (n); ++i) {
    swap(a[i].sa, a[i].sb);
    swap(a[i].ea, a[i].eb);
  }
  swap(m1, m2);
  if (check()) puts("YES");
  return 0;
}
