#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int n;
struct REC {
  int a, b, c, d;
} rec[N];
bool cmp1(REC& p, REC& q) { return p.a < q.a; }
bool cmp2(REC& p, REC& q) { return p.b < q.b; }
bool solve(int l, int r) {
  if (l == r) return 1;
  sort(rec + l, rec + r + 1, cmp1);
  int xmax = 0;
  for (int i = l; i <= r - 1; i++) {
    xmax = max(xmax, rec[i].c);
    if (rec[i + 1].a >= xmax) return solve(l, i) && solve(i + 1, r);
  }
  sort(rec + l, rec + r + 1, cmp2);
  int ymax = 0;
  for (int i = l; i <= r - 1; i++) {
    ymax = max(ymax, rec[i].d);
    if (rec[i + 1].b >= ymax) return solve(l, i) && solve(i + 1, r);
  }
  return 0;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++)
      scanf("%d%d%d%d", &rec[i].a, &rec[i].b, &rec[i].c, &rec[i].d);
    if (solve(1, n))
      puts("YES");
    else
      printf("NO");
  }
  return 0;
}
