#include <bits/stdc++.h>
using namespace std;
const int N = 100007;
int n, t, xe, ye, A[N], X1[N], X2[N], Y1[N], Y2[N], XE[N << 1], YE[N << 1];
bool cmpX(int x, int y) { return X1[x] < X1[y]; }
bool cmpY(int x, int y) { return Y1[x] < Y1[y]; }
bool spl(int l, int r, int o) {
  if (l == r) return 1;
  if (o) {
    sort(A + l, A + 1 + r, cmpX);
    int ls = l, mx = X2[A[l]];
    for (int i = l + 1; i <= r; ++i) {
      if (X1[A[i]] >= mx) {
        if (!spl(ls, i - 1, o ^ 1)) return 0;
        ls = i;
      }
      mx = max(mx, X2[A[i]]);
    }
    if (ls == l || !spl(ls, r, o ^ 1)) return 0;
  } else {
    sort(A + l, A + 1 + r, cmpY);
    int ls = l, mx = Y2[A[l]];
    for (int i = l + 1; i <= r; ++i) {
      if (Y1[A[i]] >= mx) {
        if (!spl(ls, i - 1, o ^ 1)) return 0;
        ls = i;
      }
      mx = max(mx, Y2[A[i]]);
    }
    if (ls == l || !spl(ls, r, o ^ 1)) return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
    XE[++xe] = X1[i], XE[++xe] = X2[i];
    YE[++ye] = Y1[i], YE[++ye] = Y2[i];
  }
  sort(XE + 1, XE + 1 + xe), xe = unique(XE + 1, XE + 1 + xe) - XE - 1;
  sort(YE + 1, YE + 1 + ye), ye = unique(YE + 1, YE + 1 + ye) - YE - 1;
  for (int i = 1; i <= n; ++i) {
    X1[i] = lower_bound(XE + 1, XE + 1 + xe, X1[i]) - XE,
    X2[i] = lower_bound(XE + 1, XE + 1 + xe, X2[i]) - XE;
    Y1[i] = lower_bound(YE + 1, YE + 1 + ye, Y1[i]) - YE,
    Y2[i] = lower_bound(YE + 1, YE + 1 + ye, Y2[i]) - YE;
  }
  for (int i = 1; i <= n; ++i) A[i] = i;
  if (spl(1, n, 0)) {
    puts("YES");
    return 0;
  }
  for (int i = 1; i <= n; ++i) A[i] = i;
  if (spl(1, n, 1)) {
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}
