#include <bits/stdc++.h>
using namespace std;
int n;
struct Rect {
  int a, b, c, d;
  Rect() { a = b = c = d = 0; }
  Rect(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
};
Rect rect[1000];
bool cmpR(const Rect& r1, const Rect& r2) {
  if (r1.a != r2.a) return r1.a < r2.a;
  return r1.c < r2.c;
}
bool cmpD(const Rect& r1, const Rect& r2) {
  if (r1.b != r2.b) return r1.b < r2.b;
  return r1.d < r2.d;
}
bool check(int l, int r) {
  if (l == r) return true;
  sort(rect + l, rect + r + 1, cmpR);
  int maxL = rect[l].c;
  for (int i = l + 1; i <= r; i++) {
    if (maxL <= rect[i].a) return check(l, i - 1) && check(i, r);
    maxL = max(maxL, rect[i].c);
  }
  sort(rect + l, rect + r + 1, cmpD);
  int maxD = rect[l].d;
  for (int i = l + 1; i <= r; i++) {
    if (maxD <= rect[i].b) return check(l, i - 1) && check(i, r);
    maxD = max(maxD, rect[i].d);
  }
  return false;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> rect[i].a >> rect[i].b >> rect[i].c >> rect[i].d;
  }
  if (check(0, n - 1))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
