#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
struct printer {
  ~printer() { cerr << endl; }
  template <class c>
  printer& operator,(c x) {
    cerr << boolalpha << x;
    return *this;
  }
  printer& operator,(string x) {
    cerr << x;
    return *this;
  }
  template <class c, class d>
  printer& operator,(pair<c, d> x) {
    return *this, "(", x.first, ", ", x.second, ")";
  }
  template <class... d, template <class...> class c>
  printer& operator,(c<d...> x) {
    return *this, range(begin(x), end(x));
  }
  template <class c>
  printer& operator,(rge<c> x) {
    *this, "[";
    for (auto it = x.b; it != x.e; ++it) *this, (it == x.b ? "" : ", "), *it;
    return *this, "]";
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
const int N = 1005;
struct Rect {
  int x1, y1, x2, y2;
} R[N];
bool xcomp(Rect a, Rect b) {
  return make_pair(a.x1, a.x2) < make_pair(b.x1, b.x2);
}
bool ycomp(Rect a, Rect b) {
  return make_pair(a.y1, a.y2) < make_pair(b.y1, b.y2);
}
void solve(int l, int r) {
  if (l >= r) return;
  sort(R + l, R + r + 1, xcomp);
  int xmin = R[l].x1, xmax = R[l].x2;
  for (int i = l + 1; i <= r; i++) {
    if (R[i].x1 >= xmax) {
      solve(l, i - 1);
      solve(i, r);
      return;
    }
    xmax = max(xmax, R[i].x2);
  }
  sort(R + l, R + r + 1, ycomp);
  int ymin = R[l].y1, ymax = R[l].y2;
  for (int i = l + 1; i <= r; i++) {
    if (R[i].y1 >= ymax) {
      solve(l, i - 1);
      solve(i, r);
      return;
    }
    ymax = max(ymax, R[i].y2);
  }
  cout << "NO" << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
  }
  solve(0, n - 1);
  cout << "YES" << endl;
}
