#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
struct node {
  int x1, y1, x2, y2;
} a[N], c[N];
int n, tot, b[N << 2], sum[N << 2];
bool solve(int l, int r) {
  if (l == r) return 1;
  for (int i = 1; i <= tot; i++) sum[i] = 0;
  for (int i = l; i <= r; i++) sum[a[i].x1 + 1]++, sum[a[i].x2]--;
  int mx = 0, mn = tot + 1, s = 0, p = -1;
  for (int i = l; i <= r; i++) mx = max(mx, a[i].x1), mn = min(mn, a[i].x2);
  for (int i = 1; i <= tot; i++) {
    s += sum[i];
    if (!s && i >= mn && i <= mx) {
      p = i;
      break;
    }
  }
  if (p != -1) {
    int u = l - 1, mid;
    for (int i = l; i <= r; i++)
      if (a[i].x2 <= p) c[++u] = a[i];
    mid = u;
    for (int i = l; i <= r; i++)
      if (a[i].x1 >= p) c[++u] = a[i];
    for (int i = l; i <= r; i++) a[i] = c[i];
    return solve(l, mid) && solve(mid + 1, r);
  }
  for (int i = 1; i <= tot; i++) sum[i] = 0;
  for (int i = l; i <= r; i++) sum[a[i].y1 + 1]++, sum[a[i].y2]--;
  mx = 0, mn = tot + 1;
  for (int i = l; i <= r; i++) mx = max(mx, a[i].y1), mn = min(mn, a[i].y2);
  s = 0, p = -1;
  for (int i = 1; i <= tot; i++) {
    s += sum[i];
    if (!s && i >= mn && i <= mx) {
      p = i;
      break;
    }
  }
  if (p != -1) {
    int u = l - 1, mid;
    for (int i = l; i <= r; i++)
      if (a[i].y2 <= p) c[++u] = a[i];
    mid = u;
    for (int i = l; i <= r; i++)
      if (a[i].y1 >= p) c[++u] = a[i];
    for (int i = l; i <= r; i++) a[i] = c[i];
    return solve(l, mid) && solve(mid + 1, r);
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x1), b[++tot] = a[i].x1;
    scanf("%d", &a[i].y1), b[++tot] = a[i].y1;
    scanf("%d", &a[i].x2), b[++tot] = a[i].x2;
    scanf("%d", &a[i].y2), b[++tot] = a[i].y2;
  }
  sort(b + 1, b + tot + 1);
  tot = unique(b + 1, b + tot + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    a[i].x1 = lower_bound(b + 1, b + tot + 1, a[i].x1) - b;
    a[i].y1 = lower_bound(b + 1, b + tot + 1, a[i].y1) - b;
    a[i].x2 = lower_bound(b + 1, b + tot + 1, a[i].x2) - b;
    a[i].y2 = lower_bound(b + 1, b + tot + 1, a[i].y2) - b;
  }
  if (solve(1, n))
    puts("YES");
  else
    puts("NO");
}
