#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1005;
int n, a[N], b[N], c[N], d[N];
bool check(vector<int> iv, bool dir) {
  if (iv.size() == 1) return true;
  sort(iv.begin(), iv.end(), [&](int i, int j) {
    return dir ? tie(a[i], c[i]) < tie(a[j], c[j])
               : tie(b[i], d[i]) < tie(b[j], d[j]);
  });
  bool ok = false;
  int pre = 0, right = -1;
  for (size_t ii = 0; ii < iv.size(); ii++) {
    int i = iv[ii];
    int l = dir ? a[i] : b[i];
    int r = dir ? c[i] : d[i];
    if (ii && l >= right) {
      ok = true;
      if (!check(vector<int>(iv.begin() + pre, iv.begin() + ii), !dir))
        return false;
      pre = ii;
    }
    right = max(right, r);
  }
  if (!ok) return false;
  return check(vector<int>(iv.begin() + pre, iv.end()), !dir);
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i)
    scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
  vector<int> iv;
  for (int i = 1; i <= n; i++) iv.push_back(i);
  if (check(iv, true) || check(iv, false))
    printf("YES\n");
  else
    printf("NO\n");
}
