#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, pair<int, int> > > X;
bool cmp1(pair<pair<int, int>, pair<int, int> > a,
          pair<pair<int, int>, pair<int, int> > b) {
  return a.first.first < b.first.first;
}
bool cmp2(pair<pair<int, int>, pair<int, int> > a,
          pair<pair<int, int>, pair<int, int> > b) {
  return a.first.second < b.first.second;
}
int solve(int left, int right) {
  if (left == right) return 1;
  sort(X.begin() + left, X.begin() + right + 1, cmp1);
  int done = X[left].second.first;
  for (int i = left + 1; i <= right; i++) {
    if (X[i].first.first >= done) return solve(left, i - 1) & solve(i, right);
    done = max(done, X[i].second.first);
  }
  sort(X.begin() + left, X.begin() + right + 1, cmp2);
  done = X[left].second.second;
  for (int i = left + 1; i <= right; i++) {
    if (X[i].first.second >= done) return solve(left, i - 1) & solve(i, right);
    done = max(done, X[i].second.second);
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    X.push_back({{a, b}, {c, d}});
  }
  if (solve(0, N - 1))
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
