#include <bits/stdc++.h>
using namespace std;
const pair<long long, long long> dxy[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
const long long mod = 1e9 + 7;
const long long inf = 2e18;
const long double eps = 1e-9;
const long long NN = 1e5 + 2;
struct rectangle {
  long long lox, loy;
  long long upx, upy;
};
bool sort_x(rectangle& a, rectangle& b) { return a.upx < b.upx; }
bool sort_y(rectangle& a, rectangle& b) { return a.upy < b.upy; }
vector<rectangle> v;
bool recur(long long l, long long r) {
  if (r - l <= 2) return 1;
  sort(v.begin() + l, v.begin() + r, sort_x);
  bool done = false;
  for (long long i = r - 1, sofar = v[r - 1].lox; i > l;
       i--, sofar = min(sofar, v[i].lox)) {
    if (v[i - 1].upx <= sofar) {
      done = recur(l, i) and recur(i, r);
      break;
    }
  }
  if (done) return 1;
  sort(v.begin() + l, v.begin() + r, sort_y);
  for (long long i = r - 1, sofar = v[r - 1].loy; i > l;
       i--, sofar = min(sofar, v[i].loy)) {
    if (v[i - 1].upy <= sofar) {
      done = recur(l, i) and recur(i, r);
      break;
    }
  }
  return done;
}
void solve() {
  long long i = 0, j = 0, k = 0, n = 0, m = 0;
  cin >> n;
  v.resize(n);
  for (i = 0; i < (n); i++) {
    cin >> v[i].lox >> v[i].loy >> v[i].upx >> v[i].upy;
  }
  cout << (recur(0, n) ? "YES" : "NO") << '\n';
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long T = 1, tc;
  for (tc = 1; tc <= T; tc++) {
    solve();
  }
  return 0;
}
