#include <bits/stdc++.h>
using namespace std;
class end_point {
 public:
  int value;
  int ending;
  int index;
  int venue;
  bool operator<(const end_point& x) const {
    if (value == x.value) return ending < x.ending;
    return value < x.value;
  }
};
void set_end_point(end_point* p, int v, int e, int i, int ven) {
  p->ending = e;
  p->value = v;
  p->index = i;
  p->venue = ven;
}
bool check(vector<end_point>& A, vector<pair<end_point, end_point> >& inB,
           int n) {
  multiset<int> B_b;
  multiset<int> B_e;
  vector<end_point> a;
  for (int i = 0; i < A.size(); i++) a.push_back(A[i]);
  sort(a.begin(), a.end());
  for (int i = 0; i < 2 * n; i++) {
    if (a[i].ending == -1) {
      if (B_b.empty() == false) {
        set<int>::iterator it;
        it = B_b.end();
        it--;
        int b = *it;
        it = B_e.begin();
        int e = *it;
        if ((inB[a[i].index].first.value > e ||
             inB[a[i].index].second.value < b))
          return false;
      }
      B_b.insert(inB[a[i].index].first.value);
      B_e.insert(inB[a[i].index].second.value);
    } else {
      B_b.erase(B_b.find(inB[a[i].index].first.value));
      B_e.erase(B_e.find(inB[a[i].index].second.value));
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "YES" << endl;
    return 0;
  }
  vector<end_point> A;
  vector<end_point> B;
  vector<pair<end_point, end_point> > InA;
  vector<pair<end_point, end_point> > InB;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    end_point p, q;
    set_end_point(&p, a, -1, i, 1);
    A.push_back(p);
    set_end_point(&q, b, 1, i, 1);
    A.push_back(q);
    InA.push_back(make_pair(p, q));
    set_end_point(&p, c, -1, i, 2);
    B.push_back(p);
    set_end_point(&q, d, 1, i, 2);
    B.push_back(q);
    InB.push_back(make_pair(p, q));
  }
  if (check(A, InB, n) == false)
    cout << "NO" << endl;
  else if (check(B, InA, n) == false)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
