#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n;
long long l[2][N], r[2][N];
vector<long long> vL[N], vR[N];
bool Mobed(bool b) {
  for (long long i = 0; i < N; i++) vL[i].clear(), vR[i].clear();
  for (long long i = 0; i < n; i++)
    vL[l[b][i]].push_back(i), vR[r[b][i]].push_back(i);
  multiset<long long> lt, rt;
  for (long long i = 0; i < N; i++) {
    for (long long x : vL[i]) lt.insert(l[b ^ 1][x]), rt.insert(r[b ^ 1][x]);
    for (long long x : vR[i]) {
      long long mn = *rt.begin();
      long long mx = *lt.rbegin();
      if (mx > r[b ^ 1][x] || mn < l[b ^ 1][x]) return false;
    }
    for (long long x : vR[i])
      lt.erase(lt.find(l[b ^ 1][x])), rt.erase(rt.find(r[b ^ 1][x]));
  }
  return true;
}
int32_t main() {
  cin >> n;
  vector<long long> comp;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 2; j++)
      cin >> l[j][i] >> r[j][i], comp.push_back(l[j][i]),
          comp.push_back(r[j][i]);
  sort(comp.begin(), comp.end());
  comp.resize(unique(comp.begin(), comp.end()) - comp.begin());
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < 2; j++) {
      l[j][i] =
          lower_bound(comp.begin(), comp.end(), l[j][i]) - comp.begin() + 1;
      r[j][i] =
          lower_bound(comp.begin(), comp.end(), r[j][i]) - comp.begin() + 1;
    }
  cout << (Mobed(0) & Mobed(1) ? "YES" : "NO") << endl;
  ;
  return 0;
}
