#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
struct Event {
  int l[2], r[2];
};
Event e[N];
struct CMP {
  int t;
  bool operator()(Event a, Event b) { return a.l[t] < b.l[t]; }
  CMP(int t) : t(t) {}
  Event make(int val) {
    Event x;
    memset(&x, 0, sizeof(x));
    x.l[t] = val;
    return x;
  }
};
int lmax[17][N], rmin[17][N], Log2[N];
void build(int a) {
  if (Log2[0] != -1) {
    Log2[0] = -1;
    for (int i = 1; i <= n; ++i) Log2[i] = Log2[i >> 1] + 1;
  }
  for (int i = 1; i <= n; ++i) lmax[0][i] = e[i].l[a], rmin[0][i] = e[i].r[a];
  for (int j = 1; (1 << j) <= n; ++j)
    for (int i = 1; i + (1 << j) - 1 <= n; ++i)
      lmax[j][i] = max(lmax[j - 1][i], lmax[j - 1][i + (1 << j - 1)]),
      rmin[j][i] = min(rmin[j - 1][i], rmin[j - 1][i + (1 << j - 1)]);
}
void get(int l, int r, int &lmx, int &rmn) {
  int s = Log2[r - l + 1];
  lmx = max(lmax[s][l], lmax[s][r - (1 << s) + 1]);
  rmn = min(rmin[s][l], rmin[s][r - (1 << s) + 1]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> e[i].l[0] >> e[i].r[0] >> e[i].l[1] >> e[i].r[1];
  for (int a = 0; a < 2; ++a) {
    CMP cmp(a);
    sort(e + 1, e + 1 + n, cmp);
    build(a ^ 1);
    for (int i = 1, lmx, rmn; i <= n; ++i) {
      int l = i + 1,
          r = upper_bound(e + i + 1, e + 1 + n, cmp.make(e[i].r[a]), cmp) - e -
              1;
      if (l > r) continue;
      get(l, r, lmx, rmn);
      if (lmx > e[i].r[a ^ 1] || rmn < e[i].l[a ^ 1]) return puts("NO") & 0;
    }
  }
  return puts("YES") & 0;
}
