#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n, long long m) {
  if (n == 0) return m;
  return gcd(m % n, n);
}
bool ifprime(long long n) {
  if (n == 1) return false;
  long long i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void disp(vector<long long> v) {
  for (auto u : v) cout << u << " ";
  cout << "\n";
}
void remleadzero(vector<int> &v) {
  vector<int> u;
  int i = 0;
  while (v[i] == 0) i++;
  while (i < v.size()) {
    u.push_back(v[i]);
    i++;
  }
  v = u;
}
long long fast_expo(long long n, long long m, long long md) {
  long long a = 1;
  while (m > 0) {
    if (m & 1) a = (a * n) % md;
    n = (n * n) % md;
    m /= 2;
  }
  return a % md;
}
long long sqroot(long long n) {
  long double N = n;
  N = sqrtl(N);
  long long sq = N - 2;
  sq = max(sq, 0LL);
  while (sq * sq < n) {
    sq++;
  }
  if ((sq * sq) == n) return sq;
  return -1;
}
bool check(vector<pair<int, pair<int, int>>> &a,
           vector<pair<int, pair<int, int>>> &b, vector<pair<int, int>> &pa,
           vector<pair<int, int>> &push_back) {
  sort((a).begin(), (a).end());
  multiset<int> L, R;
  for (auto u : a) {
    int v = u.first, t = u.second.first, i = u.second.second;
    if (t == -1) {
      if (L.empty()) {
        L.insert(push_back[i].first);
        R.insert(push_back[i].second);
      } else {
        auto it = L.end();
        it--;
        int lmx = (*it);
        it = R.begin();
        int rmn = (*it);
        if (push_back[i].first <= rmn and push_back[i].second >= lmx) {
          L.insert(push_back[i].first);
          R.insert(push_back[i].second);
        } else {
          cout << "NO";
          return 0;
        }
      }
    } else {
      if (!L.empty()) {
        L.erase(L.find(push_back[i].first));
        R.erase(R.find(push_back[i].second));
      }
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<pair<int, pair<int, int>>> a, b;
  vector<pair<int, int>> pa, push_back;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.emplace_back(x, make_pair(-1, i));
    a.emplace_back(y, make_pair(1, i));
    pa.emplace_back(x, y);
    cin >> x >> y;
    b.emplace_back(x, make_pair(-1, i));
    b.emplace_back(y, make_pair(1, i));
    push_back.emplace_back(x, y);
  }
  if (check(a, b, pa, push_back) and check(b, a, push_back, pa)) cout << "YES";
  return 0;
}
