#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
};
vector<rect> a;
bool cmp1(rect x, rect y) { return x.x1 < y.x1; }
bool cmp2(rect x, rect y) { return x.y1 < y.y1; }
int f(vector<rect> tmp) {
  if (tmp.size() == 1) {
    return 1;
  }
  sort(tmp.begin(), tmp.end(), cmp1);
  vector<rect> b, c;
  b.push_back(tmp[0]);
  int mx = tmp[0].x2;
  for (int i = 1; i < tmp.size(); i++) {
    if (mx <= tmp[i].x1) {
      for (int j = i; j < tmp.size(); j++) c.push_back(tmp[j]);
      return (f(b) && f(c));
    }
    mx = max(mx, tmp[i].x2);
    b.push_back(tmp[i]);
  }
  b.clear();
  c.clear();
  sort(tmp.begin(), tmp.end(), cmp2);
  b.push_back(tmp[0]);
  mx = tmp[0].y2;
  for (int i = 1; i < tmp.size(); i++) {
    if (mx <= tmp[i].y1) {
      for (int j = i; j < tmp.size(); j++) c.push_back(tmp[j]);
      return (f(b) && f(c));
    }
    mx = max(mx, tmp[i].y2);
    b.push_back(tmp[i]);
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
  }
  if (f(a)) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}
