#include <bits/stdc++.h>
using namespace std;
struct SegTree {
  vector<int> tree, lazy;
  int base;
  SegTree(int a) {
    base = 1;
    while (base < a) base <<= 1;
    tree.resize(base * 2 + 2);
    lazy.resize(base * 2 + 2);
    base--;
  }
  void propagate(int ns, int nf, int num) {
    if (lazy[num] != 0) {
      if (ns < nf) {
        lazy[num * 2] += lazy[num];
        lazy[num * 2 + 1] += lazy[num];
      }
      tree[num] += lazy[num];
      lazy[num] = 0;
    }
  }
  void update(int val, int st, int fn, int ns = 1, int nf = -1, int num = 1) {
    if (nf == -1) nf = base + 1;
    propagate(ns, nf, num);
    if (nf < st || fn < ns) return;
    if (st <= ns && nf <= fn) {
      lazy[num] += val;
      propagate(ns, nf, num);
      return;
    }
    int mid = (ns + nf) >> 1;
    update(val, st, fn, ns, mid, num * 2);
    update(val, st, fn, mid + 1, nf, num * 2 + 1);
    tree[num] = max(tree[num * 2], tree[num * 2 + 1]);
  }
  int query(int st, int fn, int ns = 1, int nf = -1, int num = 1) {
    if (nf == -1) nf = base + 1;
    propagate(ns, nf, num);
    if (nf < st || fn < ns) return 0;
    if (st <= ns && nf <= fn) return tree[num];
    int mid = (ns + nf) >> 1;
    return max(query(st, fn, ns, mid, num * 2),
               query(st, fn, mid + 1, nf, num * 2 + 1));
  }
};
struct A {
  int s1, f1, s2, f2;
  A() {}
  A(int a, int b, int c, int d) : s1(a), f1(b), s2(c), f2(d) {}
};
bool cmp(const A &x, const A &y) {
  return (x.s1 == y.s1) ? x.f1 < y.f1 : x.s1 < y.s1;
}
int n;
A m[100005];
vector<int> t;
bool solve() {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      PQ;
  SegTree T((int)t.size());
  for (int i = 1; i <= n; i++) {
    while (!PQ.empty() && PQ.top().first < m[i].s1) {
      pair<int, int> val = PQ.top();
      PQ.pop();
      int idx = val.second;
      T.update(-1, m[idx].s2, m[idx].f2);
    }
    PQ.push(pair<int, int>(m[i].f1, i));
    T.update(1, m[i].s2, m[i].f2);
    if (T.query(m[i].s2, m[i].f2) != (int)PQ.size()) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d %d", &m[i].s1, &m[i].f1, &m[i].s2, &m[i].f2);
    t.push_back(m[i].s1);
    t.push_back(m[i].f1);
    t.push_back(m[i].s2);
    t.push_back(m[i].f2);
  }
  sort(m + 1, m + 1 + n, cmp);
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  for (int i = 1; i <= n; i++) {
    int v = m[i].s1;
    m[i].s1 = lower_bound(t.begin(), t.end(), v) - t.begin() + 1;
    v = m[i].f1;
    m[i].f1 = lower_bound(t.begin(), t.end(), v) - t.begin() + 1;
    v = m[i].s2;
    m[i].s2 = lower_bound(t.begin(), t.end(), v) - t.begin() + 1;
    v = m[i].f2;
    m[i].f2 = lower_bound(t.begin(), t.end(), v) - t.begin() + 1;
  }
  if (!solve()) {
    printf("NO");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    swap(m[i].s1, m[i].s2);
    swap(m[i].f1, m[i].f2);
  }
  sort(m + 1, m + 1 + n, cmp);
  if (!solve()) {
    printf("NO");
    return 0;
  }
  printf("YES");
  return 0;
}
