#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long md = 1000) {
  long long res = 1;
  x %= md;
  while (y > 0) {
    if (y & 1) res = (res * x) % md;
    x = (x * x) % md;
    y = y >> 1;
  }
  return res % md;
}
long long seg[400005][2];
pair<long long, long long> query(long long index, long long ss, long long se,
                                 long long qs, long long qe) {
  if (qs > qe) return {1000000000000000000, -1000000000000000000};
  if (ss >= qs && se <= qe) {
    return {seg[index][0], seg[index][1]};
  }
  if (ss > qe || se < qs) return {1000000000000000000, -1000000000000000000};
  long long mid = (ss + se) / 2;
  pair<long long, long long> a = query(index * 2 + 1, ss, mid, qs, qe);
  pair<long long, long long> b = query(index * 2 + 2, mid + 1, se, qs, qe);
  return {min(a.first, b.first), max(a.second, b.second)};
}
void update(long long index, long long ss, long long se, long long loc,
            pair<long long, long long> val) {
  if (ss > loc || se < loc) return;
  if (ss == se) {
    seg[index][0] = val.second;
    seg[index][1] = val.first;
    return;
  }
  long long mid = (ss + se) / 2;
  update(index * 2 + 1, ss, mid, loc, val);
  update(index * 2 + 2, mid + 1, se, loc, val);
  seg[index][0] = min(seg[index * 2 + 1][0], seg[index * 2 + 2][0]);
  seg[index][1] = max(seg[index * 2 + 1][1], seg[index * 2 + 2][1]);
}
bool cmp(pair<pair<long long, long long>, pair<long long, long long>> a,
         pair<pair<long long, long long>, pair<long long, long long>> b) {
  return a.first.second < b.first.second;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long first = 1;
  vector<pair<pair<long long, long long>, pair<long long, long long>>> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i].first.first >> v[i].first.second >> v[i].second.first >>
        v[i].second.second;
  }
  vector<pair<pair<long long, long long>, pair<long long, long long>>> back = v;
  sort(v.begin(), v.end(), cmp);
  for (long long i = 0; i < n; i++) {
    update(0, 0, n - 1, i, {v[i].second.first, v[i].second.second});
  }
  vector<long long> ends;
  for (long long i = 0; i < n; i++) {
    long long num =
        ends.end() - lower_bound(ends.begin(), ends.end(), v[i].first.first);
    ends.push_back(v[i].first.second);
    if (num == 0) continue;
    pair<long long, long long> q = query(0, 0, n - 1, i - num, i - 1);
    long long l = q.second;
    long long r = q.first;
    if (r < v[i].second.first || l > v[i].second.second) first = 0;
  }
  v = back;
  for (long long i = 0; i < n; i++) swap(v[i].first, v[i].second);
  sort(v.begin(), v.end(), cmp);
  for (long long i = 0; i < n; i++) {
    update(0, 0, n - 1, i, {v[i].second.first, v[i].second.second});
  }
  ends.clear();
  for (long long i = 0; i < n; i++) {
    long long num =
        ends.end() - lower_bound(ends.begin(), ends.end(), v[i].first.first);
    ends.push_back(v[i].first.second);
    if (num == 0) continue;
    pair<long long, long long> q = query(0, 0, n - 1, i - num, i - 1);
    long long l = q.second;
    long long r = q.first;
    if (r < v[i].second.first || l > v[i].second.second) first = 0;
  }
  if (first)
    cout << "YES";
  else
    cout << "NO";
}
