#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const long long MAXN = 100005;
int n;
struct Data {
  pair<int, int> a, b;
} sa[MAXN], sb[MAXN];
bool sort_by_l(const Data &d1, const Data &d2) {
  return d1.a.first < d2.a.first;
}
bool sort_by_r(const Data &d1, const Data &d2) {
  return d1.a.second < d2.a.second;
}
vector<int> val;
void dis(int &x) {
  x = lower_bound(val.begin(), val.end(), x) - val.begin() + 1;
}
const int MAXC = 400005;
int seg[MAXC * 4], tag[MAXC * 4];
void push(int o) {
  if (tag[o]) {
    seg[o] += tag[o];
    tag[o << 1] += tag[o];
    tag[o << 1 | 1] += tag[o];
    tag[o] = 0;
  }
}
int get(int o) { return seg[o] + tag[o]; }
void pull(int o) { seg[o] = max(get(o << 1), get(o << 1 | 1)); }
void add(int qL, int qR, int v, int o, int nL, int nR) {
  if (qL >= qR || qL >= nR || qR <= nL) {
    return;
  } else if (qL <= nL && nR <= qR) {
    tag[o] += v;
  } else {
    int nM = (nL + nR) >> 1;
    push(o);
    add(qL, qR, v, o << 1, nL, nM);
    add(qL, qR, v, o << 1 | 1, nM, nR);
    pull(o);
  }
}
int qry(int qL, int qR, int o, int nL, int nR) {
  if (qL >= qR || qL >= nR || qR <= nL) {
    return 0;
  } else if (qL <= nL && nR <= qR) {
    return get(o);
  } else {
    int nM = (nL + nR) >> 1;
    push(o);
    return max(qry(qL, qR, o << 1, nL, nM), qry(qL, qR, o << 1 | 1, nM, nR));
  }
}
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < (n); i += 1) {
    cin >> sa[i].a.first >> sa[i].a.second;
    cin >> sa[i].b.first >> sa[i].b.second;
    val.emplace_back(sa[i].a.first);
    val.emplace_back(sa[i].a.second);
    val.emplace_back(sa[i].b.first);
    val.emplace_back(sa[i].b.second);
  }
  sort(val.begin(), val.end());
  val.resize(unique(val.begin(), val.end()) - val.begin());
  for (int i = 0; i < (n); i += 1) {
    dis(sa[i].a.first);
    dis(sa[i].a.second);
    dis(sa[i].b.first);
    dis(sa[i].b.second);
  }
  int fail = false;
  for (int u = 0; u < (2); u += 1) {
    memset(seg, (0), sizeof(seg));
    memset(tag, (0), sizeof(tag));
    for (int i = 0; i < (n); i += 1) {
      swap(sa[i].a, sa[i].b);
      sb[i] = sa[i];
    }
    sort(sa, sa + n, sort_by_r);
    sort(sb, sb + n, sort_by_l);
    int ida = 0;
    for (int i = 0; i < (n); i += 1) {
      while (ida < n && sa[ida].a.second < sb[i].a.first) {
        add(sa[ida].b.first, sa[ida].b.second + 1, 1, 1, 0, MAXC);
        ida++;
      }
      if (qry(sb[i].b.first, sb[i].b.second + 1, 1, 0, MAXC) > 0) {
        fail = true;
      }
    }
  }
  cout << (fail ? "NO" : "YES") << '\n';
  return 0;
}
