#include <bits/stdc++.h>
using namespace std;
const int N = 510031;
int n;
int l1[N], r1[N], l2[N], r2[N];
multiset<int> right_ends;
multiset<int> left_ends;
multiset<int>::iterator it;
vector<pair<int, pair<int, int> > > events;
bool solver() {
  right_ends.clear();
  left_ends.clear();
  for (int i = 0; i < events.size(); i++) {
    int id = events[i].second.second;
    if (events[i].second.first == -1) {
      right_ends.insert(r2[id]);
      left_ends.insert(l2[id]);
    } else {
      right_ends.erase(right_ends.find(r2[id]));
      left_ends.erase(left_ends.find(l2[id]));
    }
    if (left_ends.size() > 0) {
      it = left_ends.end();
      --it;
      int rmost_start = (*it);
      it = right_ends.begin();
      int lmost_end = (*it);
      if (lmost_end < rmost_start) return 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l1[i] >> r1[i] >> l2[i] >> r2[i];
    events.push_back(make_pair(l1[i], make_pair(-1, i)));
    events.push_back(make_pair(r1[i], make_pair(1, i)));
  }
  sort(events.begin(), events.end());
  int ans = solver();
  events.clear();
  for (int i = 0; i < n; i++) {
    swap(l1[i], l2[i]);
    swap(r1[i], r2[i]);
    events.push_back(make_pair(l1[i], make_pair(-1, i)));
    events.push_back(make_pair(r1[i], make_pair(1, i)));
  }
  sort(events.begin(), events.end());
  ans = (ans | solver());
  if (ans)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
