#include <bits/stdc++.h>
using namespace std;
long long n, sa, ea, sb, eb;
multiset<long long> st, ed;
vector<pair<pair<long long, long long>, pair<long long, long long> > > fst, snd;
bool cmp(pair<pair<long long, long long>, pair<long long, long long> > a,
         pair<pair<long long, long long>, pair<long long, long long> > b) {
  if (a.first.first < b.first.first) {
    return true;
  }
  if (a.first.first > b.first.first) {
    return false;
  }
  if (a.second.second < b.second.second) {
    return true;
  }
  return false;
}
int main() {
  long long i, ta, tb;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> sa >> ea >> sb >> eb;
    fst.push_back(make_pair(make_pair(sa, sb), make_pair(eb, (long long)1)));
    fst.push_back(
        make_pair(make_pair(ea + 1, sb), make_pair(eb, (long long)0)));
    snd.push_back(make_pair(make_pair(sb, sa), make_pair(ea, (long long)1)));
    snd.push_back(
        make_pair(make_pair(eb + 1, sa), make_pair(ea, (long long)0)));
  }
  sort(fst.begin(), fst.end(), cmp);
  sort(snd.begin(), snd.end(), cmp);
  st.clear();
  ed.clear();
  for (i = 0; i < fst.size(); i++) {
    if (fst[i].second.second == 0) {
      st.erase(st.find(fst[i].first.second));
      ed.erase(ed.find(fst[i].second.first));
    } else {
      if (st.empty()) {
        st.insert(fst[i].first.second);
        ed.insert(fst[i].second.first);
        continue;
      }
      ta = *(st.rbegin());
      tb = *(ed.begin());
      if (ta > fst[i].second.first || tb < fst[i].first.second) {
        puts("NO");
        return 0;
      }
      st.insert(fst[i].first.second);
      ed.insert(fst[i].second.first);
    }
  }
  st.clear();
  ed.clear();
  for (i = 0; i < snd.size(); i++) {
    if (snd[i].second.second == 0) {
      st.erase(st.find(snd[i].first.second));
      ed.erase(ed.find(snd[i].second.first));
    } else {
      if (st.empty()) {
        st.insert(snd[i].first.second);
        ed.insert(snd[i].second.first);
        continue;
      }
      ta = *(st.rbegin());
      tb = *(ed.begin());
      if (ta > snd[i].second.first || tb < snd[i].first.second) {
        puts("NO");
        return 0;
      }
      st.insert(snd[i].first.second);
      ed.insert(snd[i].second.first);
    }
  }
  puts("YES");
  return 0;
}
