#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
const int INF = ~(1 << 31);
const double EPS = 1e-12;
const double PI = 3.141592653589793;
int main() {
  int n;
  cin >> n;
  vector<pair<pair<int, int>, pair<int, int> > > v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i].first.first >> v[i].second.first >> v[i].first.second >>
        v[i].second.second;
  int l = -1, r = -1;
  int start = 0;
  bool finish = 0;
  for (int i = 0; i < 31401; i++) {
    vector<pair<int, int> > a;
    for (int j = 0; j < n; j++) {
      if (i >= v[j].first.first && i < v[j].first.second) {
        a.push_back(v[j].second);
      }
    }
    if (a.size() > 0) {
      if (finish) {
        cout << "NO\n";
        return 0;
      }
      start++;
    } else {
      if (start && !finish) {
        finish = 1;
        if (start != r - l) {
          cout << "NO\n";
          return 0;
        }
      }
      continue;
    }
    sort((a).begin(), (a).end());
    if (l == -1) {
      l = a[0].first;
      r = a[a.size() - 1].second;
    } else {
      if (l != a[0].first || r != a[a.size() - 1].second) {
        cout << "NO\n";
        return 0;
      }
    }
    for (int j = 0; j < a.size() - 1; j++) {
      if (a[j].second != a[j + 1].first) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
