#include <bits/stdc++.h>
using namespace std;
struct rect {
  int a, b, c, d;
};
int part(const vector<pair<int, int> > &evt) {
  int bal = 0;
  for (int i = 0; i < (int)(((int)(evt).size())); i++) {
    auto xy = evt[i];
    bal += xy.second;
    if (bal == 0 && i + 1 < ((int)(evt).size())) return xy.first;
  }
  return -1;
}
bool divide(const vector<rect> &R) {
  if (((int)(R).size()) == 1) return true;
  vector<pair<int, int> > evt;
  for (auto rr : R) {
    evt.emplace_back(rr.a, +1);
    evt.emplace_back(rr.c, -1);
  }
  sort((evt).begin(), (evt).end());
  int mid = part(evt);
  if (mid != -1) {
    vector<rect> l, r;
    for (auto rr : R)
      if (rr.c <= mid)
        l.push_back(rr);
      else
        r.push_back(rr);
    return divide(l) && divide(r);
  }
  evt.clear();
  for (auto rr : R) {
    evt.emplace_back(rr.b, +1);
    evt.emplace_back(rr.d, -1);
  }
  sort((evt).begin(), (evt).end());
  mid = part(evt);
  if (mid != -1) {
    vector<rect> u, d;
    for (auto rr : R) {
      if (rr.d <= mid)
        u.push_back(rr);
      else
        d.push_back(rr);
    }
    return divide(u) && divide(d);
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<rect> r(n);
  for (auto &rr : r) cin >> rr.a >> rr.b >> rr.c >> rr.d;
  cout << (divide(r) ? "YES" : "NO");
  return 0;
}
