#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const long long MOD = 1e9 + 7;
int N, M, K, Q;
vector<pair<int, int>> vec[2];
bool solve(int opt) {
  vector<pair<int, int>> &A = vec[opt];
  vector<pair<int, int>> &B = vec[!opt];
  vector<pair<int, int>> line;
  for (int i = 0; i < A.size(); ++i) {
    line.push_back({A[i].first, i});
    line.push_back({A[i].second + 1, i});
  }
  sort(line.begin(), line.end());
  set<pair<int, int>> minR;
  set<pair<int, int>> maxL;
  for (int i = 0; i < line.size(); ++i) {
    int point = line[i].first;
    int idx = line[i].second;
    if (maxL.find({B[idx].first, idx}) == maxL.end()) {
      maxL.insert({B[idx].first, idx});
      minR.insert({B[idx].second, idx});
    } else {
      maxL.erase({B[idx].first, idx});
      minR.erase({B[idx].second, idx});
    }
    if (i != line.size() - 1 && point == line[i + 1].first) continue;
    if (!maxL.empty()) {
      auto itmax = maxL.end();
      --itmax;
      auto itmin = minR.begin();
      if (itmax->first > itmin->first) return false;
    }
  }
  return true;
}
int main() {
  int i, j, l, r;
  scanf("%d", &N);
  for (i = 0; i < N; ++i) {
    scanf("%d%d", &l, &r);
    vec[0].push_back({l, r});
    scanf("%d%d", &l, &r);
    vec[1].push_back({l, r});
  }
  bool flag = solve(0);
  if (!flag) {
    printf("NO");
    return 0;
  }
  flag = solve(1);
  if (!flag) {
    printf("NO");
    return 0;
  }
  printf("YES");
  return 0;
}
