#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int NINF = 0x3f3f3f40;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0x3f3f3f3f3f3f3f40;
const int mxN = 1001;
array<int, 4> rects[mxN];
int n;
bool compx(array<int, 4> a, array<int, 4> b) {
  if (a[0] == b[0]) {
    return a[2] < b[2];
  } else {
    return a[0] < b[0];
  }
}
bool compy(array<int, 4> a, array<int, 4> b) {
  if (a[1] == b[1]) {
    return a[3] < b[3];
  } else {
    return a[1] < b[1];
  }
}
bool ok = true;
bool solve(int start = 0, int end = n - 1) {
  if (end - start + 1 <= 1) return true;
  sort(rects + start, rects + end + 1, compx);
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = (start); i < (end + 1); ++i) {
    while (!pq.empty() && pq.top() <= rects[i][0]) pq.pop();
    if (i > start && pq.empty()) {
      return solve(start, i - 1) && solve(i, end);
    }
    pq.push(rects[i][2]);
  }
  sort(rects + start, rects + end + 1, compy);
  while (!pq.empty()) pq.pop();
  for (int i = (start); i < (end + 1); ++i) {
    while (!pq.empty() && pq.top() <= rects[i][1]) pq.pop();
    if (i > start && pq.empty()) {
      return solve(start, i - 1) && solve(i, end);
    }
    pq.push(rects[i][3]);
  }
  for (int i = (start); i < (end + 1); ++i) {
  }
  return false;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    cin >> rects[i][0] >> rects[i][1] >> rects[i][2] >> rects[i][3];
  }
  cout << (solve() ? "YES\n" : "NO\n");
  return 0;
}
