#include <bits/stdc++.h>
using namespace std;
const int inf = 1e+9;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
int main() {
  int n;
  cin >> n;
  vector<char> mas(32500);
  vector<vector<int> > a;
  vector<pair<pair<int, int>, int> > ev;
  for (int i = 0; i < n; i++) {
    vector<int> tmp(4);
    for (int k = 0; k < 4; k++) {
      cin >> tmp[k];
    }
    tmp[3] -= 1;
    a.push_back(tmp);
    ev.push_back(make_pair(make_pair(tmp[0], 1), i));
    ev.push_back(make_pair(make_pair(tmp[2], -1), i));
  }
  sort(ev.begin(), ev.end());
  bool first = true;
  int minl = inf;
  int maxh = -1;
  bool good = true;
  for (int i = 0; i < ev.size(); i++) {
    if (first && ev[i].first.first != ev[0].first.first) {
      first = false;
      for (int j = minl; j <= maxh; j++) {
        if (mas[j] == 0) {
          good = false;
        }
      }
    }
    if (i - 1 >= 0 && ev[i].first.first != ev[i - 1].first.first) {
      for (int j = minl; j <= maxh; j++) {
        if (mas[j] == 0) {
          good = false;
        }
      }
    }
    int sob = ev[i].first.second;
    int p = ev[i].second;
    int l = a[p][1];
    if (first)
      minl = min(minl, l);
    else {
      if (l < minl) good = false;
    }
    int h = a[p][3];
    if (first)
      maxh = max(maxh, h);
    else {
      if (h > maxh) good = false;
    }
    if (sob == 1) {
      for (int j = l; j <= h; j++) mas[j] = 1;
    } else {
      for (int j = l; j <= h; j++) mas[j] = 0;
    }
  }
  if (good && ev.back().first.first - ev[0].first.first == maxh - minl + 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
