#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, a[N], b[N], c[N], d[N];
vector<vector<int> > v;
vector<int> v2, v3;
vector<pair<int, int> > tmp;
bool check(int i) {
  tmp.clear();
  for (int j = 0; j < (int)v[i].size(); j++) {
    tmp.push_back(make_pair(a[v[i][j]], c[v[i][j]]));
  }
  sort(tmp.begin(), tmp.end());
  int last = -1, good = -1;
  for (int j = 0; j < (int)tmp.size(); j++) {
    if (last != -1 && tmp[j].first >= last) {
      good = last;
      break;
    }
    last = max(last, tmp[j].second);
  }
  if (good != -1) {
    v2.clear();
    v3.clear();
    for (int j = 0; j < (int)v[i].size(); j++) {
      if (a[v[i][j]] >= good)
        v2.push_back(v[i][j]);
      else
        v3.push_back(v[i][j]);
    }
    v[i] = v2;
    v.push_back(v3);
    return true;
  }
  tmp.clear();
  for (int j = 0; j < (int)v[i].size(); j++) {
    tmp.push_back(make_pair(b[v[i][j]], d[v[i][j]]));
  }
  sort(tmp.begin(), tmp.end());
  last = -1, good = -1;
  for (int j = 0; j < (int)tmp.size(); j++) {
    if (last != -1 && tmp[j].first >= last) {
      good = last;
      break;
    }
    last = max(last, tmp[j].second);
  }
  if (good != -1) {
    v2.clear();
    v3.clear();
    for (int j = 0; j < (int)v[i].size(); j++) {
      if (b[v[i][j]] >= good)
        v2.push_back(v[i][j]);
      else
        v3.push_back(v[i][j]);
    }
    v[i] = v2;
    v.push_back(v3);
    return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  v.resize(1);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
    v[0].push_back(i);
  }
  bool can = false;
  for (int i = 0; i < n - 1; i++) {
    can = false;
    for (int j = 0; j < (int)v.size(); j++) {
      if (check(j)) {
        can = true;
        break;
      }
    }
    if (!can) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
