#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x, y, id;
  rect(int x, int y, int id) {
    this->x = x;
    this->y = y;
    this->id = id;
  }
  friend bool operator<(rect a, rect b) {
    if (a.x != b.x) return a.x < b.x;
    if (a.y != b.y) return a.y < b.y;
    return a.id < b.id;
  }
};
const int maxn = 100000;
int x[maxn][2], y[maxn][2];
bool works(set<rect> a[4]) {
  if (a[0].size() == 1) return 1;
  int mx[4];
  int n = a[0].size();
  set<rect>::iterator it[4], st;
  for (int i = 0; i < 4; i++) it[i] = a[i].begin(), mx[i] = it[i]->y, it[i]++;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < 4; j++) {
      if (mx[j] <= it[j]->x) {
        set<rect> b[4];
        b[0].clear(), b[1].clear(), b[2].clear(), b[3].clear();
        for (st = a[j].begin(); st != it[j];) {
          int v = st->id;
          st++;
          b[0].insert(rect(x[v][0], x[v][1], v));
          b[1].insert(rect(-x[v][1], -x[v][0], v));
          b[2].insert(rect(y[v][0], y[v][1], v));
          b[3].insert(rect(-y[v][1], -y[v][0], v));
          a[0].erase(rect(x[v][0], x[v][1], v));
          a[1].erase(rect(-x[v][1], -x[v][0], v));
          a[2].erase(rect(y[v][0], y[v][1], v));
          a[3].erase(rect(-y[v][1], -y[v][0], v));
        }
        return works(a) && works(b);
      }
      mx[j] = max(mx[j], it[j]->y);
      it[j]++;
    }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  set<rect> r[4];
  for (int i = 0; i < n; i++) {
    cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
    r[0].insert(rect(x[i][0], x[i][1], i));
    r[1].insert(rect(-x[i][1], -x[i][0], i));
    r[2].insert(rect(y[i][0], y[i][1], i));
    r[3].insert(rect(-y[i][1], -y[i][0], i));
  }
  if (works(r))
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
  return 0;
}
