#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, id;
  bool operator<(const node &o) const {
    if (l != o.l) return l < o.l;
    if (r != o.r) return r < o.r;
    return id < o.id;
  }
} p[100005][4];
int n;
set<node> s[4];
bool ok(set<node> a[4]) {
  int n = a[0].size(), ma[4];
  set<node>::iterator it[4];
  if (n == 1) return 1;
  for (int i = 0; i <= 3; i++) {
    it[i] = a[i].begin();
    ma[i] = -1e9;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= 3; j++) {
      ma[j] = max(ma[j], it[j]->r), ++it[j];
      if ((it[j]->l) >= ma[j]) {
        set<node> b[4];
        for (int o = 1; o <= i; o++) {
          int id = a[j].begin()->id;
          for (int k = 0; k <= 3; k++) {
            a[k].erase(p[id][k]);
            b[k].insert(p[id][k]);
          }
        }
        return ok(a) && ok(b);
      }
    }
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, a, b, c, d; i <= n; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    s[0].insert(p[i][0] = (node){a, c, i});
    s[1].insert(p[i][1] = (node){-c, -a, i});
    s[2].insert(p[i][2] = (node){b, d, i});
    s[3].insert(p[i][3] = (node){-d, -b, i});
  }
  if (ok(s))
    puts("Yes");
  else
    puts("No");
}
