#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3;
int n;
struct point {
  int x, y;
};
struct rr {
  point dl, gd;
} rec[maxn + 10];
bool srt_x1(rr a, rr b) { return a.dl.x < b.dl.x; }
bool srt_x2(rr a, rr b) { return a.gd.x < b.gd.x; }
bool srt_y1(rr a, rr b) { return a.dl.y < b.dl.y; }
bool srt_y2(rr a, rr b) { return a.gd.y < b.gd.y; }
int try_vert_cut1(int l, int r) {
  sort(rec + l, rec + r + 1, srt_x1);
  int maxx = rec[l].gd.x;
  for (int i = l + 1; i <= r; i++) {
    if (maxx <= rec[i].dl.x) return i - 1;
    maxx = max(maxx, rec[i].gd.x);
  }
  return -1;
}
int try_vert_cut2(int l, int r) {
  sort(rec + l, rec + r + 1, srt_x2);
  int maxx = rec[r].dl.x;
  for (int i = r - 1; i >= l; i--) {
    if (maxx >= rec[i].gd.x) return i + 1;
    maxx = min(maxx, rec[i].dl.x);
  }
  return -1;
}
int try_hor_cut1(int l, int r) {
  sort(rec + l, rec + r + 1, srt_y1);
  int maxx = rec[l].gd.y;
  for (int i = l + 1; i <= r; i++) {
    if (maxx <= rec[i].dl.y) return i - 1;
    maxx = max(maxx, rec[i].gd.y);
  }
  return -1;
}
int try_hor_cut2(int l, int r) {
  sort(rec + l, rec + r + 1, srt_y2);
  int maxx = rec[r].dl.y;
  for (int i = r - 1; i >= l; i--) {
    if (maxx >= rec[i].gd.y) return i + 1;
    maxx = min(maxx, rec[i].dl.y);
  }
  return -1;
}
bool go(int l, int r) {
  if (l == r) return 1;
  int x = try_vert_cut1(l, r);
  if (x != -1) return (go(l, x) & go(x + 1, r));
  x = try_vert_cut2(l, r);
  if (x != -1) return (go(l, x) & go(x + 1, r));
  x = try_hor_cut1(l, r);
  if (x != -1) return (go(l, x) & go(x + 1, r));
  x = try_hor_cut2(l, r);
  if (x != -1) return (go(l, x) & go(x + 1, r));
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d %d %d %d", &rec[i].dl.x, &rec[i].dl.y, &rec[i].gd.x,
          &rec[i].gd.y);
  if (go(1, n))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
