#include <bits/stdc++.h>
using namespace std;
long long const max_N = 1e5 + 5;
long long N, sa[max_N], ea[max_N], sb[max_N], eb[max_N];
bool check(long long as[], long long ae[], long long bs[], long long be[]) {
  multiset<long long> s, e;
  vector<tuple<long long, long long, long long, long long> > events;
  for (int i = 0; i < N; i++) {
    tuple<long long, long long, long long, long long> str = {as[i], 1, bs[i],
                                                             be[i]},
                                                      end = {ae[i] + 1, 0,
                                                             bs[i], be[i]};
    events.emplace_back(str);
    events.emplace_back(end);
  }
  sort(events.begin(), events.end());
  for (auto &ev : events) {
    if (get<1>(ev)) {
      if (!s.empty()) {
        long long maxS = *s.rbegin(), minE = *e.begin();
        if (maxS > get<3>(ev) || minE < get<2>(ev)) return false;
      }
      s.insert(get<2>(ev));
      e.insert(get<3>(ev));
    } else {
      s.erase(s.find(get<2>(ev)));
      e.erase(e.find(get<3>(ev)));
    }
  }
  return true;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> sa[i] >> ea[i] >> sb[i] >> eb[i];
  }
  cout << ((check(sa, ea, sb, eb) && check(sb, eb, sa, ea)) ? "YES\n" : "NO\n");
}
