#include <bits/stdc++.h>
using namespace std;
bool isOk(const vector<pair<int, int> >& a, const vector<pair<int, int> >& b) {
  vector<pair<int, int> > apt(a.size() * 2);
  for (int i = 0; i < a.size(); i++) {
    apt[2 * i] = make_pair(a[i].first, -(i + 1));
    apt[2 * i + 1] = make_pair(a[i].second, (i + 1));
  }
  sort(apt.begin(), apt.end());
  multiset<int> bs;
  multiset<int> be;
  for (int i = 0; i < apt.size(); i++) {
    int id = apt[i].second;
    if (id < 0) {
      id = -id - 1;
      if (!bs.empty()) {
        int gbs = *bs.rbegin();
        int gbe = *be.begin();
        if (max(gbs, b[id].first) > min(gbe, b[id].second)) {
          return false;
        }
      }
      bs.insert(b[id].first);
      be.insert(b[id].second);
    } else {
      id--;
      bs.erase(bs.find(b[id].first));
      be.erase(be.find(b[id].second));
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > b(n);
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second >> b[i].first >> b[i].second;
  }
  bool bOk = isOk(a, b) && isOk(b, a);
  cout << (bOk ? "YES" : "NO") << endl;
  return 0;
}
