#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
};
bool divide(vector<rect> v) {
  if (v.size() == 1) {
    return true;
  }
  int n = v.size();
  sort(v.begin(), v.end(), [](rect f, rect s) {
    return (f.x1 == s.x1) ? (f.x2 < s.x2) : (f.x1 < s.x1);
  });
  int right_bound = v[0].x2;
  for (int i = 1; i < n; i++) {
    if (right_bound <= v[i].x1) {
      vector<rect> f, s;
      for (int j = 0; j < i; j++) {
        f.push_back(v[j]);
      }
      for (int j = i; j < n; j++) {
        s.push_back(v[j]);
      }
      return (divide(f) && divide(s));
    }
    right_bound = max(right_bound, v[i].x2);
  }
  sort(v.begin(), v.end(), [](rect f, rect s) {
    return (f.y1 == s.y1) ? (f.y2 < s.y2) : (f.y1 < s.y1);
  });
  int low_bound = v[0].y2;
  for (int i = 1; i < n; i++) {
    if (low_bound <= v[i].y1) {
      vector<rect> f, s;
      for (int j = 0; j < i; j++) {
        f.push_back(v[j]);
      }
      for (int j = i; j < n; j++) {
        s.push_back(v[j]);
      }
      return (divide(f) && divide(s));
    }
    low_bound = max(low_bound, v[i].y2);
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<rect> r(n);
  for (int i = 0; i < n; i++) {
    cin >> r[i].x1 >> r[i].y1 >> r[i].x2 >> r[i].y2;
  }
  if (divide(r)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
