#include <bits/stdc++.h>
using namespace std;
struct q {
  long long x1, x2, y1, y2, ind;
};
bool check(list<q> a) {
  if (a.size() < 2) return true;
  set<long long> was;
  list<q> left((a).begin(), (a).end()), right((a).begin(), (a).end()),
      up((a).begin(), (a).end()), down((a).begin(), (a).end());
  left.sort([](const q& a, const q& b) { return a.x1 < b.x1; });
  right.sort([](const q& a, const q& b) { return a.x2 > b.x2; });
  up.sort([](const q& a, const q& b) { return a.y1 < b.y1; });
  down.sort([](const q& a, const q& b) { return a.y2 > b.y2; });
  long long cnt = 0;
  long long brd = -1;
  for (auto it = ++left.begin(); it != left.end(); it++) {
    cnt++;
    auto prev = it;
    prev--;
    brd = max(brd, prev->x2);
    if (brd <= it->x1 && cnt * 2 <= left.size()) {
      if (!check(list<q>(left.begin(), it))) return false;
      while (left.begin() != it) {
        was.insert(left.begin()->ind);
        left.pop_front();
      }
    }
  }
  for (auto it = right.begin(); it != right.end();) {
    if (was.count(it->ind))
      it = right.erase(it);
    else
      it++;
  }
  cnt = 0, brd = 1000000007ll * 123;
  for (auto it = ++right.begin(); it != right.end(); it++) {
    cnt++;
    auto prev = it;
    prev--;
    brd = min(brd, prev->x1);
    if (brd >= it->x2 && cnt * 2 <= right.size()) {
      if (!check(list<q>(right.begin(), it))) return false;
      while (right.begin() != it) {
        was.insert(right.begin()->ind);
        right.pop_front();
      }
    }
  }
  for (auto it = up.begin(); it != up.end();) {
    if (was.count(it->ind))
      it = up.erase(it);
    else
      it++;
  }
  cnt = 0, brd = -1;
  for (auto it = ++up.begin(); it != up.end(); it++) {
    cnt++;
    auto prev = it;
    prev--;
    brd = max(brd, prev->y2);
    if (brd <= it->y1 && cnt * 2 <= up.size()) {
      if (!check(list<q>(up.begin(), it))) return false;
      while (up.begin() != it) {
        was.insert(up.begin()->ind);
        up.pop_front();
      }
    }
  }
  for (auto it = down.begin(); it != down.end();) {
    if (was.count(it->ind))
      it = down.erase(it);
    else
      it++;
  }
  cnt = 0, brd = 1000000007ll * 123;
  for (auto it = ++down.begin(); it != down.end(); it++) {
    cnt++;
    auto prev = it;
    prev--;
    brd = min(brd, prev->y1);
    if (brd >= it->y2 && cnt * 2 <= down.size()) {
      if (!check(list<q>(down.begin(), it))) return false;
      while (down.begin() != it) down.pop_front();
    }
  }
  if (down.size() == a.size()) return false;
  return check(down);
}
void Solve() {
  long long n;
  cin >> n;
  list<q> a;
  for (signed i = 0; i < (n); i++) {
    q z;
    cin >> z.x1 >> z.y1 >> z.x2 >> z.y2;
    z.ind = i;
    a.push_back(z);
  }
  cout << (check(a) ? "YES" : "NO");
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
