#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000], b[100000], c[100000], d[100000];
struct x_inc {
  bool operator()(const int &l, const int &r) const {
    if (a[l] == a[r]) return l < r;
    return a[l] < a[r];
  }
};
struct x_dec {
  bool operator()(const int &l, const int &r) const {
    if (c[l] == c[r]) return l < r;
    return c[l] > c[r];
  }
};
struct y_inc {
  bool operator()(const int &l, const int &r) const {
    if (b[l] == b[r]) return l < r;
    return b[l] < b[r];
  }
};
struct y_dec {
  bool operator()(const int &l, const int &r) const {
    if (d[l] == d[r]) return l < r;
    return d[l] > d[r];
  }
};
void calc(set<int, x_inc> &l, set<int, x_dec> &r, set<int, y_inc> &u,
          set<int, y_dec> &o) {
  if (l.size() <= 1) return;
  auto pl = l.begin();
  auto pr = r.begin();
  auto pu = u.begin();
  auto po = o.begin();
  int cl = c[*pl], cr = a[*pr], cu = d[*pu], co = b[*po];
  for (int i = 1; i < l.size(); ++i) {
    pl++;
    pr++;
    pu++;
    po++;
    if (a[*pl] >= cl) {
      set<int, x_inc> newl;
      set<int, x_dec> newr;
      set<int, y_inc> newu;
      set<int, y_dec> newo;
      auto it = l.begin();
      while (it != pl) {
        newl.insert(*it);
        newr.insert(*it);
        newu.insert(*it);
        newo.insert(*it);
        r.erase(*it);
        u.erase(*it);
        o.erase(*it);
        it = l.erase(it);
      }
      calc(newl, newr, newu, newo);
      calc(l, r, u, o);
      return;
    } else if (c[*pr] <= cr) {
      set<int, x_inc> newl;
      set<int, x_dec> newr;
      set<int, y_inc> newu;
      set<int, y_dec> newo;
      auto it = r.begin();
      while (it != pr) {
        newl.insert(*it);
        newr.insert(*it);
        newu.insert(*it);
        newo.insert(*it);
        l.erase(*it);
        u.erase(*it);
        o.erase(*it);
        it = r.erase(it);
      }
      calc(newl, newr, newu, newo);
      calc(l, r, u, o);
      return;
    } else if (b[*pu] >= cu) {
      set<int, x_inc> newl;
      set<int, x_dec> newr;
      set<int, y_inc> newu;
      set<int, y_dec> newo;
      auto it = u.begin();
      while (it != pu) {
        newl.insert(*it);
        newr.insert(*it);
        newu.insert(*it);
        newo.insert(*it);
        l.erase(*it);
        r.erase(*it);
        o.erase(*it);
        it = u.erase(it);
      }
      calc(newl, newr, newu, newo);
      calc(l, r, u, o);
      return;
    } else if (d[*po] <= co) {
      set<int, x_inc> newl;
      set<int, x_dec> newr;
      set<int, y_inc> newu;
      set<int, y_dec> newo;
      auto it = o.begin();
      while (it != po) {
        newl.insert(*it);
        newr.insert(*it);
        newu.insert(*it);
        newo.insert(*it);
        l.erase(*it);
        r.erase(*it);
        u.erase(*it);
        it = o.erase(it);
      }
      calc(newl, newr, newu, newo);
      calc(l, r, u, o);
      return;
    } else {
      cl = max(cl, c[*pl]);
      cr = min(cr, a[*pr]);
      cu = max(cu, d[*pu]);
      co = min(co, b[*po]);
    }
  }
  cout << "NO\n";
  exit(0);
}
int main() {
  cin >> n;
  set<int, x_inc> newl;
  set<int, x_dec> newr;
  set<int, y_inc> newu;
  set<int, y_dec> newo;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    newl.insert(i);
    newr.insert(i);
    newu.insert(i);
    newo.insert(i);
  }
  calc(newl, newr, newu, newo);
  cout << "YES\n";
}
