#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(double a, double b) {
  return fabs(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(int num, int idx) { return num ^ (1 << idx); }
void FS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int a[100100][3][3];
bool cmpx(int i1, int i2) { return a[i1][0][0] < a[i2][0][0]; }
bool cmpy(int i1, int i2) { return a[i1][0][1] < a[i2][0][1]; }
bool solve(vector<int> v) {
  if (((int)(v).size()) == 1) return 1;
  for (int t = 0; t <= 1; t++) {
    if (t == 0)
      sort(((v).begin()), ((v).end()), cmpx);
    else
      sort(((v).begin()), ((v).end()), cmpy);
    int lim = a[v[0]][1][t];
    for (int i = 0; i < ((int)(v).size()); i++) {
      int nw = a[v[i]][0][t];
      if (nw >= lim) {
        vector<int> a, b;
        for (int k = 0; k < i; k++) a.push_back(v[k]);
        for (int k = i; k < ((int)(v).size()); k++) b.push_back(v[k]);
        return (solve(a) & solve(b));
      }
      lim = max(lim, a[v[i]][1][t]);
    }
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0][0] >> a[i][0][1] >> a[i][1][0] >> a[i][1][1];
    v.push_back(i);
  }
  cout << (solve(v) ? "YES" : "NO") << endl;
}
