#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n;
pair<int, int> a[N], b[N];
bool cmp(const pair<int, pair<int, int>>& lhs,
         const pair<int, pair<int, int>>& rhs) {
  if (lhs.first == rhs.first) {
    return lhs.second.second > rhs.second.second;
  }
  return lhs.first < rhs.first;
};
vector<pair<int, pair<int, int>>> timeline;
multiset<pair<int, int>> lec_start, lec_end;
bool solve(pair<int, int> vA[], pair<int, int> vB[]) {
  timeline.clear();
  lec_start.clear();
  lec_end.clear();
  for (int i = 0; i < n; i++) {
    timeline.push_back({vA[i].first, {i, 0}});
    timeline.push_back({vA[i].second + 1, {i, 1}});
  }
  sort(timeline.begin(), timeline.end(), cmp);
  for (int i = 0; i < timeline.size();) {
    int cur_val = timeline[i].first;
    while (i < timeline.size() && timeline[i].first == cur_val) {
      int idx = timeline[i].second.first, state = timeline[i].second.second;
      if (!state) {
        if (!lec_start.empty()) {
          int max_start = (*lec_start.rbegin()).first,
              min_end = (*lec_end.begin()).first;
          if (vB[idx].first > min_end || vB[idx].second < max_start) {
            return false;
          }
        }
        lec_start.insert({vB[idx].first, idx});
        lec_end.insert({vB[idx].second, idx});
      } else {
        lec_start.erase({vB[idx].first, idx});
        lec_end.erase({vB[idx].second, idx});
      }
      i++;
    }
  }
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    cin >> b[i].first >> b[i].second;
  }
  bool ans = 1;
  ans &= solve(a, b);
  ans &= solve(b, a);
  if (ans) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
