#include <bits/stdc++.h>
using namespace std;
bool check(vector<pair<int, int>>& a, vector<pair<int, int>>& b) {
  vector<tuple<int, int, int>> events;
  for (int i = 0; i < a.size(); i++) {
    events.push_back({a[i].first, 1, i});
    events.push_back({a[i].second, 2, i});
  }
  sort(events.begin(), events.end());
  bool res = true;
  multiset<int> maxs, mine;
  for (auto& event : events) {
    int type, idx;
    tie(ignore, type, idx) = event;
    if (type == 1) {
      int s = maxs.empty() ? INT_MIN : *maxs.rbegin();
      int e = mine.empty() ? INT_MAX : *mine.begin();
      res = res && b[idx].first <= e && b[idx].second >= s;
      maxs.insert(b[idx].first);
      mine.insert(b[idx].second);
    } else {
      maxs.erase(b[idx].first);
      mine.erase(b[idx].second);
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second >> b[i].first >> b[i].second;
  }
  bool res = check(a, b) && check(b, a);
  if (res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
