#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct area {
  int u, d, l, r;
};
int n;
bool cmp_x(const area& x, const area& y) { return x.l < y.l; }
bool cmp_y(const area& x, const area& y) { return x.u < y.u; }
pair<vector<area>, vector<area> > split(vector<area>& ar) {
  vector<area> l, r;
  if (ar.size() == 1) return make_pair(l, r);
  sort(ar.begin(), ar.end(), cmp_x);
  int maxR = ar.begin()->r;
  for (register int i = 1; i < ar.size(); i++)
    if (maxR <= ar[i].l) {
      l = vector<area>(ar.begin(), ar.begin() + i);
      r = vector<area>(ar.begin() + i, ar.end());
      return pair<vector<area>, vector<area> >(l, r);
    } else {
      maxR = max(maxR, ar[i].r);
    }
  sort(ar.begin(), ar.end(), cmp_y);
  int maxD = ar.begin()->d;
  for (register int i = 1; i < ar.size(); i++)
    if (maxD <= ar[i].u) {
      l = vector<area>(ar.begin(), ar.begin() + i);
      r = vector<area>(ar.begin() + i, ar.end());
      return pair<vector<area>, vector<area> >(l, r);
    } else {
      maxD = max(maxD, ar[i].d);
    }
  cout << "NO" << endl;
  exit(0);
}
signed main() {
  vector<area> dat;
  cin >> n;
  for (register int i = 1; i <= n; i++) {
    area ar;
    cin >> ar.l >> ar.u >> ar.r >> ar.d;
    dat.push_back(ar);
  }
  queue<vector<area> > que;
  que.push(dat);
  while (!que.empty()) {
    pair<vector<area>, vector<area> > get = split(que.front());
    que.pop();
    if (get.first.empty() && get.second.empty()) continue;
    que.push(get.first);
    que.push(get.second);
  }
  cout << "YES" << endl;
  return 0;
}
