#include <bits/stdc++.h>
using namespace std;
int n;
pair<pair<int, int>, pair<int, int> > a[100009];
int segmini[400009];
int segmaxi[400009];
void build(int v, int tl, int tr) {
  if (tl > tr) return;
  if (tl == tr) {
    segmini[v] = a[tl].second.second;
    segmaxi[v] = a[tl].second.first;
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    segmini[v] = min(segmini[2 * v], segmini[2 * v + 1]);
    segmaxi[v] = max(segmaxi[2 * v], segmaxi[2 * v + 1]);
  }
}
pair<int, int> get(int v, int tl, int tr, int l, int r) {
  if (tl > r || tr < l) return {1e9, -1e9};
  if (l <= tl && tr <= r)
    return {segmini[v], segmaxi[v]};
  else {
    int tm = (tl + tr) / 2;
    pair<int, int> a = get(2 * v, tl, tm, l, r);
    pair<int, int> b = get(2 * v + 1, tm + 1, tr, l, r);
    return {min(a.first, b.first), max(a.second, b.second)};
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> a[i].first.first >> a[i].first.second >> a[i].second.first >>
        a[i].second.second;
  sort(a, a + n);
  build(1, 0, n - 1);
  for (int i = n - 1; i >= 0; --i) {
    int upper = upper_bound(a, a + n,
                            make_pair(make_pair(a[i].first.second, (int)1e9),
                                      make_pair((int)1e9, (int)1e9))) -
                a;
    --upper;
    pair<int, int> pr = get(1, 0, n - 1, i, upper);
    if (pr.first < a[i].second.first || pr.second > a[i].second.second) {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    swap(a[i].first.first, a[i].second.first);
    swap(a[i].first.second, a[i].second.second);
  }
  sort(a, a + n);
  build(1, 0, n - 1);
  for (int i = n - 1; i >= 0; --i) {
    int upper = upper_bound(a, a + n,
                            make_pair(make_pair(a[i].first.second, (int)1e9),
                                      make_pair((int)1e9, (int)1e9))) -
                a;
    --upper;
    pair<int, int> pr = get(1, 0, n - 1, i, upper);
    if (pr.first < a[i].second.first || pr.second > a[i].second.second) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
}
