#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (auto& i : a) in >> i;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  for (auto& i : a) {
    out << i << " ";
  }
  return out;
}
template <typename T, typename D>
istream& operator>>(istream& in, pair<T, D>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T, typename D>
ostream& operator<<(ostream& out, const pair<T, D>& a) {
  out << a.first << " " << a.second;
  return out;
}
const long long INFL = 9187201950435737471;
const long long nINFL = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const unsigned long long ULINF = numeric_limits<unsigned long long>::max();
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
inline void IO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long MAXN = 250;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
void MyAssert(bool f = 0) {
  if (!f) {
    cout << "NO";
    exit(0);
  }
}
void rec(vector<pair<pair<int, int>, pair<int, int>>> v, int typ) {
  if (v.size() <= 3) {
    return;
  }
  vector<tuple<int, int, int>> events;
  if ((typ & 1) == 0) {
    for (int i = 0; i < v.size(); i++) {
      events.emplace_back(v[i].first.first, 1, i);
      events.emplace_back(v[i].second.first, -1, i);
    }
    sort(events.begin(), events.end());
    int cnt = 0, cur_sz = 0;
    vector<int> sizes = {0};
    for (auto [pos, type, ind] : events) {
      cur_sz++;
      cnt += type;
      if (cnt == 0 && pos != get<0>(events.back())) {
        sizes.push_back(cur_sz);
      }
    }
    sizes.push_back(cur_sz);
    if (sizes.size() > 2) {
      int iL = 1, iR = (int)(sizes.size()) - 2;
      while (iL <= iR || abs(iL - iR) <= 1) {
        vector<pair<pair<int, int>, pair<int, int>>> newV;
        if (sizes[iL] - sizes[iL - 1] < sizes[iR + 1] - sizes[iR]) {
          for (int i = sizes[iL - 1] + 1; i <= sizes[iL]; i++) {
            if (get<1>(events[i]) == -1) {
              newV.push_back(v[get<2>(events[i])]);
            }
          }
          iL++;
          rec(newV, 1);
        } else {
          for (int i = sizes[iR]; i < sizes[iR + 1]; i++) {
            if (get<1>(events[i]) == -1) {
              newV.push_back(v[get<2>(events[i])]);
            }
          }
          iR--;
          rec(newV, 1);
        }
      }
      return;
    }
    MyAssert(typ == 2);
  }
  events.clear();
  for (int i = 0; i < v.size(); i++) {
    events.emplace_back(v[i].first.second, 1, i);
    events.emplace_back(v[i].second.second, -1, i);
  }
  sort(events.begin(), events.end());
  int cnt = 0, cur_sz = 0;
  vector<int> sizes = {0};
  for (auto [pos, type, ind] : events) {
    cur_sz++;
    cnt += type;
    if (cnt == 0 && pos != get<0>(events.back())) {
      sizes.push_back(cur_sz);
    }
  }
  sizes.push_back(cur_sz);
  if (sizes.size() > 2) {
    int iL = 1, iR = (int)(sizes.size()) - 2;
    while (iL <= iR || abs(iL - iR) <= 1) {
      vector<pair<pair<int, int>, pair<int, int>>> newV;
      if (sizes[iL] - sizes[iL - 1] < sizes[iR + 1] - sizes[iR]) {
        for (int i = sizes[iL - 1] + 1; i <= sizes[iL]; i++) {
          if (get<1>(events[i]) == -1) {
            newV.push_back(v[get<2>(events[i])]);
          }
        }
        iL++;
        rec(newV, 0);
      } else {
        for (int i = sizes[iR]; i < sizes[iR + 1]; i++) {
          if (get<1>(events[i]) == -1) {
            newV.push_back(v[get<2>(events[i])]);
          }
        }
        iR--;
        rec(newV, 0);
      }
    }
    return;
  }
  MyAssert();
}
void solve() {
  int n;
  cin >> n;
  vector<pair<pair<int, int>, pair<int, int>>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  rec(v, 2);
  cout << "YES";
}
signed main() {
  IO();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
