#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
struct castle {
  int a, b, c, d;
};
bool comp1(castle x, castle y) { return x.a < y.a; }
bool comp2(castle x, castle y) { return x.b < y.b; }
bool chk(vector<castle> &V) {
  if (!V.size()) return 0;
  if (V.size() == 1) return 1;
  vector<castle> V1, V2;
  sort(V.begin(), V.end(), comp1);
  for (int i = 0, mx = 0; i < V.size(); i++) {
    if (i && mx <= V[i].a) {
      for (int j = 0; j < V.size(); j++) {
        if (V[j].c <= V[i].a)
          V1.push_back(V[j]);
        else
          V2.push_back(V[j]);
      }
      if (chk(V1) && chk(V2)) return 1;
      break;
    }
    mx = max(mx, V[i].c);
  }
  V1.clear(), V2.clear();
  sort(V.begin(), V.end(), comp2);
  for (int i = 0, mx = 0; i < V.size(); i++) {
    if (i && mx <= V[i].b) {
      for (int j = 0; j < V.size(); j++) {
        if (V[j].d <= V[i].b)
          V1.push_back(V[j]);
        else
          V2.push_back(V[j]);
      }
      if (chk(V1) && chk(V2)) return 1;
      break;
    }
    mx = max(mx, V[i].d);
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  vector<castle> V;
  for (int i = 1, a, b, c, d; i <= n; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    V.push_back((castle){a, b, c, d});
  }
  printf("%s\n", chk(V) ? "YES" : "NO");
  return 0;
}
