#include <bits/stdc++.h>
using namespace std;
long long n;
bool chk(vector<array<long long, 4> > &v) {
  sort(v.begin(), v.end());
  multiset<array<long long, 3> > s;
  multiset<long long> lgst, smen;
  for (long long i = 0; i < n; i++) {
    while (s.size() && (*s.begin())[0] < v[i][0]) {
      lgst.erase(lgst.find((*s.begin())[1]));
      smen.erase(smen.find((*s.begin())[2]));
      s.erase(s.begin());
    }
    bool c1 = lgst.empty() || ((*lgst.rbegin()) <= v[i][3]);
    bool c2 = smen.empty() || ((*smen.begin()) >= v[i][2]);
    if (!(c1 && c2)) {
      return false;
    }
    s.insert({v[i][1], v[i][2], v[i][3]});
    lgst.insert(v[i][2]);
    smen.insert(v[i][3]);
  }
  return true;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<array<long long, 4> > v(n);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 4; j++) {
      cin >> v[i][j];
    }
  }
  bool poss = chk(v);
  for (long long i = 0; i < n; i++) {
    swap(v[i][0], v[i][2]);
    swap(v[i][1], v[i][3]);
  }
  poss &= chk(v);
  if (poss)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
