#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 10;
int sa[N], sb[N], ea[N], eb[N], n;
set<pair<int, int>> s;
void add(int l, int r) {
  int L = l, R = r;
  if (l >= r) return;
  auto it = s.lower_bound({l, 0});
  auto p = --it;
  ++it;
  if ((*p).second > l) {
    it = p;
    L = min(L, (*p).first);
  }
  vector<pair<int, int>> vec;
  while ((*it).first < r) {
    auto nx = ++it;
    --it;
    R = max(R, (*it).second);
    vec.push_back(*it);
    ++it;
  }
  for (auto it : vec) s.erase(it);
  s.insert({L, R});
}
void solve() {
  s.clear();
  s.insert({-1, -1});
  s.insert({1 << 30, 1 << 30});
  vector<int> vec[2];
  for (int i = 0; i < n; i++) vec[0].push_back(i), vec[1].push_back(i);
  sort(vec[0].begin(), vec[0].end(),
       [](int i, int j) { return sa[i] > sa[j]; });
  sort(vec[1].begin(), vec[1].end(),
       [](int i, int j) { return ea[i] > ea[j]; });
  int r = 0;
  for (auto i : vec[1]) {
    while (r < n && sa[vec[0][r]] > ea[i]) {
      add(sb[vec[0][r]], eb[vec[0][r]] + 1);
      r++;
    }
    auto it = s.upper_bound({eb[i], 1 << 30});
    it--;
    auto x = *it;
    x.second--;
    if (max(x.first, sb[i]) <= min(x.second, eb[i])) {
      cout << "NO\n";
      exit(0);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> sa[i] >> ea[i] >> sb[i] >> eb[i];
  solve();
  for (int i = 0; i < n; i++) {
    swap(sa[i], sb[i]);
    swap(ea[i], eb[i]);
  }
  solve();
  cout << "YES\n";
  return 0;
}
