#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  srand(time(0));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
const long long maxN = 1e5 + 5, maxM = 9, mod = 1e9 + 7, inf = 1e18;
long long n;
pair<long long, long long> a[maxN], b[maxN];
set<pair<long long, long long> > s;
vector<pair<long long, pair<long long, long long> > > events;
bool f(pair<long long, long long> f, pair<long long, long long> s) {
  return max(f.first, s.first) <= min(f.second, s.second);
}
bool ok() {
  for (long long i = 0; i < events.size(); i++) {
    long long cur = events[i].second.second;
    if (events[i].second.first == 0) {
      if (!s.empty()) {
        if (!f(b[cur], (*s.begin())) || !f(b[cur], (*--s.end()))) return false;
      }
      s.insert(b[cur]);
    } else {
      s.erase(b[cur]);
    }
  }
  return true;
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second >> b[i].first >> b[i].second;
    events.push_back({a[i].first, {0, i}});
    events.push_back({a[i].second, {1, i}});
  }
  sort(events.begin(), events.end());
  if (!ok()) {
    cout << "NO";
    return;
  }
  events.clear();
  pair<long long, long long> pr;
  for (long long i = 0; i < n; i++) {
    pr = a[i];
    a[i] = b[i];
    b[i] = pr;
    events.push_back({a[i].first, {0, i}});
    events.push_back({a[i].second, {1, i}});
  }
  sort(events.begin(), events.end());
  if (!ok()) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
