#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
int n;
pair<pair<int, int>, pair<int, int> > a[100001];
int f(int i, int j, int k) {
  if (!k)
    return max(a[i].first.first, a[j].first.first) <=
           min(a[i].first.second, a[j].first.second);
  else
    return max(a[i].second.first, a[j].second.first) <=
           min(a[i].second.second, a[j].second.second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  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);
  bool ok = true;
  for (int i = 0; i < n; i++)
    if (f(i, (i + 1) % n, 0) ^ f(i, (i + 1) % n, 1)) ok = false;
  if (ok)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
