#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct area {
  int u, d, l, r;
} ar[N];
int n;
bool cmp_x(const area& x, const area& y) { return x.l < y.l; }
bool cmp_y(const area& x, const area& y) { return x.u < y.u; }
bool solve(int l, int r) {
  if (l == r) return true;
  sort(ar + l, ar + r + 1, cmp_x);
  int maxR = ar[l].r;
  for (register int i = l + 1; i <= r; i++)
    if (maxR <= ar[i].l)
      return solve(l, i - 1) && solve(i, r);
    else
      maxR = max(maxR, ar[i].r);
  sort(ar + l, ar + r + 1, cmp_y);
  int maxD = ar[l].d;
  for (register int i = l + 1; i <= r; i++)
    if (maxD <= ar[i].u)
      return solve(l, i - 1) && solve(i, r);
    else
      maxD = max(maxD, ar[i].d);
  return false;
}
signed main() {
  cin >> n;
  for (register int i = 1; i <= n; i++)
    cin >> ar[i].l >> ar[i].u >> ar[i].r >> ar[i].d;
  if (solve(1, n))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
