#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5, mxC = 2 * mxN;
int n, a[mxN], b[mxN], c[mxN], d[mxN];
int x[mxC], y[mxC], xs, ys;
struct st {
  array<int, 2> st[1 << 19];
  int lz[1 << 19];
  void bld(int i = 1, int l = 0, int r = mxC - 1) {
    if (l == r) {
      st[i] = {0, l};
      return;
    }
    int m = (l + r) / 2;
    bld(2 * i, l, m);
    bld(2 * i + 1, m + 1, r);
    st[i] = st[2 * i];
  }
  void app(int i, int x) {
    st[i][0] += x;
    lz[i] += x;
  }
  void psh(int i) {
    app(2 * i, lz[i]);
    app(2 * i + 1, lz[i]);
    lz[i] = 0;
  }
  void upd(int l1, int r1, int x, int i = 1, int l2 = 0, int r2 = mxC - 1) {
    if (l1 > r1) return;
    if (l1 <= l2 && r2 <= r1) {
      app(i, x);
      return;
    }
    int m2 = (l2 + r2) / 2;
    psh(i);
    if (l1 <= m2) upd(l1, r1, x, 2 * i, l2, m2);
    if (m2 < r1) upd(l1, r1, x, 2 * i + 1, m2 + 1, r2);
    st[i] = min(st[2 * i], st[2 * i + 1]);
  }
  array<int, 2> qry(int l1, int r1, int i = 1, int l2 = 0, int r2 = mxC - 1) {
    if (l1 > r1) return {mxN};
    if (l1 <= l2 && r2 <= r1) return st[i];
    int m2 = (l2 + r2) / 2;
    psh(i);
    return min(
        l1 <= m2 ? qry(l1, r1, 2 * i, l2, m2) : array<int, 2>{mxN},
        m2 < r1 ? qry(l1, r1, 2 * i + 1, m2 + 1, r2) : array<int, 2>{mxN});
  }
} stx, sty;
struct ft {
  int ft[mxC + 1];
  void upd(int i, int x) {
    for (++i; i <= mxC; i += i & -i) ft[i] += x;
  }
  int qry(int i) {
    int r = 0;
    for (; i; i -= i & -i) r += ft[i];
    return r;
  }
} ftx, fty;
void rem(int i) {
  stx.upd(a[i] + 1, c[i] - 1, -1);
  sty.upd(b[i] + 1, d[i] - 1, -1);
  ftx.upd(a[i], -1);
  fty.upd(b[i], -1);
}
bool dc(vector<int> &v) {
  set<array<int, 2>> sx, sy, sx2, sy2;
  for (int i : v) {
    stx.upd(a[i] + 1, c[i] - 1, 1);
    sty.upd(b[i] + 1, d[i] - 1, 1);
    ftx.upd(a[i], 1);
    fty.upd(b[i], 1);
    sx.insert({a[i], i});
    sy.insert({b[i], i});
    sx2.insert({c[i], i});
    sy2.insert({d[i], i});
  }
  vector<vector<int>> vl;
  while (sx.size() > 3) {
    int ss = sx.size();
    vl.push_back({});
    array<int, 2> px = stx.qry((*sx.begin())[0] + 1, (*--sx2.end())[0] - 1);
    if (!px[0]) {
      if (ftx.qry(px[1]) > ss / 2) {
        auto it = --sx.end();
        while ((*it)[0] >= px[1]) {
          int i = (*it)[1];
          vl.back().push_back(i);
          rem(i);
          it = --sx.erase(it);
          sy.erase({b[i], i});
          sx2.erase({c[i], i});
          sy2.erase({d[i], i});
        }
      } else {
        auto it = sx.begin();
        while ((*it)[0] < px[1]) {
          int i = (*it)[1];
          vl.back().push_back(i);
          rem(i);
          it = sx.erase(it);
          sy.erase({b[i], i});
          sx2.erase({c[i], i});
          sy2.erase({d[i], i});
        }
      }
      continue;
    }
    array<int, 2> py = sty.qry((*sy.begin())[0] + 1, (*--sy2.end())[0] - 1);
    if (!py[0]) {
      if (fty.qry(py[1]) > ss / 2) {
        auto it = --sy.end();
        while ((*it)[0] >= py[1]) {
          int i = (*it)[1];
          vl.back().push_back(i);
          rem(i);
          sx.erase({a[i], i});
          it = --sy.erase(it);
          sx2.erase({c[i], i});
          sy2.erase({d[i], i});
        }
      } else {
        auto it = sy.begin();
        while ((*it)[0] < py[1]) {
          int i = (*it)[1];
          vl.back().push_back(i);
          rem(i);
          sx.erase({a[i], i});
          it = sy.erase(it);
          sx2.erase({c[i], i});
          sy2.erase({d[i], i});
        }
      }
      continue;
    }
    return 0;
  }
  for (array<int, 2> a : sx) rem(a[1]);
  for (vector<int> &vi : vl)
    if (!dc(vi)) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i];
  memcpy(x, a, 4 * n);
  memcpy(x + n, c, 4 * n);
  sort(x, x + 2 * n);
  xs = unique(x, x + 2 * n) - x;
  stx.bld();
  memcpy(y, b, 4 * n);
  memcpy(y + n, d, 4 * n);
  sort(y, y + 2 * n);
  ys = unique(y, y + 2 * n) - y;
  sty.bld();
  for (int i = 0; i < n; ++i) {
    a[i] = lower_bound(x, x + xs, a[i]) - x;
    c[i] = lower_bound(x, x + xs, c[i]) - x;
    b[i] = lower_bound(y, y + ys, b[i]) - y;
    d[i] = lower_bound(y, y + ys, d[i]) - y;
  }
  vector<int> v(n);
  iota(v.begin(), v.end(), 0);
  cout << (dc(v) ? "YES" : "NO");
}
