#include <bits/stdc++.h>
using namespace std;
struct Event {
  int a, b;
  int ev;
};
struct comp {
  bool operator()(const Event &ev1, const Event &ev2) const {
    if (ev1.a != ev2.a) {
      return ev1.a < ev2.a;
    } else {
      if (ev1.ev != ev2.ev)
        return ev1.ev < ev2.ev;
      else
        return ev1.b < ev2.b;
    }
  }
};
set<Event, comp> v1, v2;
bool solve(set<Event, comp> &v1, set<Event, comp> &v2) {
  if (v1.size() == 2) {
    return true;
  }
  int ok = 0;
  int nr = 0;
  int sz1 = v1.size();
  int sz2 = v2.size();
  set<Event, comp> va, vb;
  for (auto &el : v1) {
    va.insert(el);
    vb.insert({el.b, el.a, el.ev});
    sz1--;
    if (el.ev == 1) nr++;
    if (el.ev == 0) nr--;
    if (nr == 0 && sz1) {
      ok = 1;
      break;
    }
  }
  if (ok) {
    for (auto &el : va) {
      v1.erase(v1.find(el));
    }
    for (auto &el : vb) {
      v2.erase(v2.find(el));
    }
    bool rez1 = solve(va, vb);
    bool rez2 = solve(v1, v2);
    return rez1 == true && rez2 == true;
  } else {
    va.clear();
    vb.clear();
    ok = 0;
    nr = 0;
    for (auto &el : v2) {
      va.insert({el.b, el.a, el.ev});
      vb.insert(el);
      sz2--;
      if (el.ev == 1) nr++;
      if (el.ev == 0) nr--;
      if (nr == 0 && sz2) {
        ok = 1;
        break;
      }
    }
    if (ok) {
      for (auto &el : va) {
        v1.erase(v1.find(el));
      }
      for (auto &el : vb) {
        v2.erase(v2.find(el));
      }
      bool rez1 = solve(va, vb);
      bool rez2 = solve(v1, v2);
      return rez1 == true && rez2 == true;
    } else {
      return false;
    }
  }
}
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    v1.insert({x1, y1, 1});
    v1.insert({x2, y2, 0});
    v2.insert({y1, x1, 1});
    v2.insert({y2, x2, 0});
  }
  if (solve(v1, v2))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
