#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long int infi = 1e18 + 5;
long long int n;
long long int sa[N], ea[N], sb[N], eb[N];
bool func() {
  set<long long int> left, right;
  vector<pair<long long int, long long int> > v;
  for (long long int i = 1; i <= n; i++) {
    v.push_back(make_pair(sa[i], i));
    v.push_back(make_pair(ea[i] + 1, -i));
  }
  left.insert(-infi);
  right.insert(infi);
  sort(v.begin(), v.end());
  for (auto it : v) {
    if (it.second > 0) {
      long long int i = it.second;
      long long int l = max(*left.rbegin(), sb[i]);
      long long int r = min(*right.begin(), eb[i]);
      if (l > r) {
        return false;
      }
      left.insert(sb[i]);
      right.insert(eb[i]);
    } else {
      long long int i = -it.second;
      left.erase(sb[i]);
      right.erase(eb[i]);
    }
  }
  return true;
}
int main() {
  cin >> n;
  long long int i;
  for (i = 1; i <= n; i++) {
    cin >> sa[i] >> ea[i] >> sb[i] >> eb[i];
  }
  if (!func()) {
    cout << "NO";
    return 0;
  }
  for (i = 1; i <= n; i++) {
    swap(sa[i], sb[i]);
    swap(ea[i], eb[i]);
  }
  if (!func()) {
    cout << "NO";
    return 0;
  }
  cout << "YES"
       << "\n";
}
