#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
  if (y < x) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (y > x) x = y;
}
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), f = 1;
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}
struct CAS {
  int l, r, u, d;
  CAS(const int &l0 = 0, const int &r0 = 0, const int &u0 = 0,
      const int &d0 = 0)
      : l(l0), r(r0), u(u0), d(d0) {}
} seq[1005];
bool cmpl(const CAS &a, const CAS &b) { return a.l < b.l; }
bool cmpd(const CAS &a, const CAS &b) { return a.d < b.d; }
bool divide(CAS *a, int num) {
  if (num == 1) return 1;
  sort(a + 1, a + num + 1, cmpl);
  int mx = -1;
  for (int i = 1; i < num; i++) {
    mx = max(mx, a[i].r);
    if (mx <= a[i + 1].l) {
      if (divide(a, i) && divide(a + i, num - i))
        return 1;
      else
        return 0;
    }
  }
  sort(a + 1, a + num + 1, cmpd);
  mx = -1;
  for (int i = 1; i < num; i++) {
    mx = max(mx, a[i].u);
    if (mx <= a[i + 1].d) {
      if (divide(a, i) && divide(a + i, num - i))
        return 1;
      else
        return 0;
    }
  }
  return 0;
}
int n;
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(seq[i].l), read(seq[i].d);
    read(seq[i].r), read(seq[i].u);
  }
  if (divide(seq, n))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
