#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int n;
long long a[MAXN][4];
int idx[MAXN];
bool valid(int start, int end) {
  if (end - start <= 1) return true;
  long long cur;
  sort(idx + start, idx + end,
       [&](const int& i, const int& j) { return a[i][0] < a[j][0]; });
  cur = 0;
  for (int i = start; i + 1 < end; i++) {
    cur = max(cur, a[idx[i]][2]);
    if (cur <= a[idx[i + 1]][0]) {
      if (valid(start, i + 1) && valid(i + 1, end))
        return true;
      else
        return false;
    }
  }
  sort(idx + start, idx + end,
       [&](const int& i, const int& j) { return a[i][1] < a[j][1]; });
  cur = 0;
  for (int i = start; i + 1 < end; i++) {
    cur = max(cur, a[idx[i]][3]);
    if (cur <= a[idx[i + 1]][1]) {
      if (valid(start, i + 1) && valid(i + 1, end))
        return true;
      else
        return false;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) cin >> a[i][j];
  }
  for (int i = 0; i < n; i++) idx[i] = i;
  bool res = valid(0, n);
  if (res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
