#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int OFF = (1 << 18);
int tour[2 * OFF], prop[2 * OFF];
vector<int> sazA, sazB;
vector<pair<int, int> > swpA, swpB;
void refresh(int x) {
  if (!prop[x]) return;
  tour[x] += prop[x];
  if (x < OFF) {
    prop[2 * x] += prop[x];
    prop[2 * x + 1] += prop[x];
  }
  prop[x] = 0;
}
void update(int i, int a, int b, int lo, int hi, int x) {
  refresh(i);
  if (lo <= a && b <= hi) {
    prop[i] += x;
    refresh(i);
    return;
  }
  if (a > hi || b < lo) return;
  update(2 * i, a, (a + b) / 2, lo, hi, x);
  update(2 * i + 1, (a + b) / 2 + 1, b, lo, hi, x);
  tour[i] = max(tour[2 * i], tour[2 * i + 1]);
}
int query(int i, int a, int b, int lo, int hi) {
  refresh(i);
  if (lo <= a && b <= hi) return tour[i];
  if (a > hi || b < lo) return 0;
  return max(query(2 * i, a, (a + b) / 2, lo, hi),
             query(2 * i + 1, (a + b) / 2 + 1, b, lo, hi));
}
int as[N], ae[N], bs[N], be[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", as + i, ae + i, bs + i, be + i);
    sazA.push_back(as[i]), sazA.push_back(ae[i]);
    sazB.push_back(bs[i]), sazB.push_back(be[i]);
  }
  sort(sazA.begin(), sazA.end());
  sort(sazB.begin(), sazB.end());
  for (int i = 1; i <= n; i++) {
    as[i] = lower_bound(sazA.begin(), sazA.end(), as[i]) - sazA.begin();
    ae[i] = lower_bound(sazA.begin(), sazA.end(), ae[i]) - sazA.begin();
    bs[i] = lower_bound(sazB.begin(), sazB.end(), bs[i]) - sazB.begin();
    be[i] = lower_bound(sazB.begin(), sazB.end(), be[i]) - sazB.begin();
    swpA.push_back({as[i], i});
    swpA.push_back({ae[i], -i});
    swpB.push_back({bs[i], i});
    swpB.push_back({be[i], -i});
  }
  sort(swpA.begin(), swpA.end());
  memset(tour, 0, sizeof(tour));
  memset(prop, 0, sizeof(prop));
  for (int i = 1; i <= n; i++) update(1, 0, OFF - 1, bs[i], be[i], 1);
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    int j = i;
    while (j < 2 * n && swpA[i].first == swpA[j].first) j++;
    for (int k = i; k < j; k++) {
      if (swpA[k].second > 0) {
        int ind = swpA[k].second;
        update(1, 0, OFF - 1, bs[ind], be[ind], -1);
      }
    }
    for (int k = i; k < j; k++) {
      if (swpA[k].second < 0) {
        int ind = -swpA[k].second;
        if (query(1, 0, OFF - 1, bs[ind], be[ind]) > 0) ans = 1;
      }
    }
    i = j - 1;
  }
  sort(swpB.begin(), swpB.end());
  memset(tour, 0, sizeof(tour));
  memset(prop, 0, sizeof(prop));
  for (int i = 1; i <= n; i++) update(1, 0, OFF - 1, as[i], ae[i], 1);
  for (int i = 0; i < 2 * n; i++) {
    int j = i;
    while (j < 2 * n && swpB[i].first == swpB[j].first) j++;
    for (int k = i; k < j; k++) {
      if (swpB[k].second > 0) {
        int ind = swpB[k].second;
        update(1, 0, OFF - 1, as[ind], ae[ind], -1);
      }
    }
    for (int k = i; k < j; k++) {
      if (swpB[k].second < 0) {
        int ind = -swpB[k].second;
        if (query(1, 0, OFF - 1, as[ind], ae[ind]) > 0) ans = 1;
      }
    }
    i = j - 1;
  }
  if (ans)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
