#include <bits/stdc++.h>
using namespace std;
int n;
struct state {
  int low;
  int left;
  int high;
  int right;
};
vector<state> states;
int compLeft(int x, int y) { return states[x].left < states[y].left; }
int compBottom(int x, int y) { return states[x].low < states[y].low; }
bool solve(const vector<int>& arr) {
  if (arr.size() == 1) {
    return true;
  }
  vector<int> horiz = arr;
  vector<int> vert = arr;
  unordered_set<int> visited;
  sort(horiz.begin(), horiz.end(), compLeft);
  sort(vert.begin(), vert.end(), compBottom);
  bool done = false;
  int mostRight = states[horiz[0]].right;
  int mostTop = states[vert[0]].high;
  int lasth = 0;
  int lastv = 0;
  int counth = 1;
  int countv = 1;
  int count = 0;
  while (counth < arr.size() || countv < arr.size()) {
    if (counth < arr.size()) {
      if (states[horiz[counth]].left >= mostRight) {
        vector<int> reth = vector<int>();
        for (int i = lasth; i < counth; i++) {
          if (!visited.count(horiz[i])) {
            reth.push_back(horiz[i]);
            visited.insert(horiz[i]);
            count++;
          }
        }
        if (!solve(reth)) {
          return false;
        }
        lasth = counth;
        while (lasth < arr.size() && visited.count(horiz[lasth])) {
          lasth++;
        }
        counth = lasth + 1;
        while (counth < arr.size() && visited.count(horiz[counth])) {
          counth++;
        }
        if (lasth < arr.size()) {
          mostRight = states[horiz[lasth]].right;
        }
        while (lastv < arr.size() && visited.count(vert[lastv])) {
          lastv++;
        }
        countv = lastv + 1;
        while (countv < arr.size() && visited.count(vert[countv])) {
          countv++;
        }
        if (lastv < arr.size()) {
          mostTop = states[vert[lastv]].high;
        }
      } else {
        if (states[horiz[counth]].right > mostRight) {
          mostRight = states[horiz[counth]].right;
        }
        counth++;
        while (counth < arr.size() && visited.count(horiz[counth])) counth++;
      }
    }
    if (countv < arr.size()) {
      if (states[vert[countv]].low >= mostTop) {
        vector<int> retv = vector<int>();
        for (int i = lastv; i < countv; i++) {
          if (!visited.count(vert[i])) {
            retv.push_back(vert[i]);
            visited.insert(vert[i]);
            count++;
          }
        }
        if (!solve(retv)) {
          return false;
        }
        lastv = countv;
        while (lastv < arr.size() && visited.count(vert[lastv])) {
          lastv++;
        }
        countv = lastv + 1;
        while (countv < arr.size() && visited.count(vert[countv])) {
          countv++;
        }
        if (lastv < arr.size()) {
          mostTop = states[vert[lastv]].high;
        }
        while (lasth < arr.size() && visited.count(horiz[lasth])) {
          lasth++;
        }
        counth = lasth + 1;
        while (counth < arr.size() && visited.count(horiz[counth])) {
          counth++;
        }
        if (lasth < arr.size()) {
          mostRight = states[horiz[lasth]].right;
        }
      } else {
        if (states[vert[countv]].high > mostTop) {
          mostTop = states[vert[countv]].high;
        }
        countv++;
        while (countv < arr.size() && visited.count(vert[countv])) countv++;
      }
    }
  }
  if (count < arr.size() - 1) {
    return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  long long sum = 0;
  int left = 1000000000;
  int right = 0;
  int high = 0;
  int low = 1000000000;
  states = vector<state>(n);
  for (int i = 0; i < n; i++) {
    cin >> states[i].left >> states[i].low >> states[i].right >> states[i].high;
  }
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    arr[i] = i;
  }
  if (solve(arr)) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
