#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const long long INF = LLONG_MAX / 2;   const long long N = 2e5 + 1;   struct event {     long long sa;     long long ea;     long long sb;     long long eb;   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     {       long long n;       cin >> n;       vector<event> a(n);       for (long long i = 0; i < n; i++)         cin >> a[i].sa >> a[i].ea >> a[i].sb >> a[i].eb;       vector<pair<double, double> > p;       multiset<pair<double, double> > s1;       multiset<pair<double, double> > s2;       bool ans = 1;       for (long long i = 0; i < n; i++) {         p.push_back({a[i].sa, i});         p.push_back({a[i].ea + 0.5, i});       }       sort(p.begin(), p.end());       for (auto i : p) {         pair<double, double> c = {a[i.second].sb, a[i.second].eb};         if (s1.count(c)) {           s1.erase(s1.find(c));           s2.erase(s2.find({c.second, c.first}));         } else {           if (s1.empty() || (*s1.rbegin()).first <= c.second &&                                 (*s2.begin()).first >= c.first) {             s1.insert(c);             s2.insert({c.second, c.first});           } else {             ans = 0;             break;           }         }       }       s1.clear();       s2.clear();       p = vector<pair<double, double> >(0);       for (long long i = 0; i < n; i++) {         p.push_back({a[i].sb, i});         p.push_back({a[i].eb + 0.5, i});       }       sort(p.begin(), p.end());       for (auto i : p) {         pair<double, double> c = {a[i.second].sa, a[i.second].ea};         if (s1.count(c)) {           s1.erase(s1.find(c));           s2.erase(s2.find({c.second, c.first}));         } else {           if (s1.empty() || (*s1.rbegin()).first <= c.second &&                                 (*s2.begin()).first >= c.first) {             s1.insert(c);             s2.insert({c.second, c.first});           } else {             ans = 0;             break;           }         }       }       if (ans)         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }   