#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a[N], b[N], c[N], d[N];
set<pair<int, int> >::iterator it;
struct S {
  set<pair<int, int> > st[2];
  int last[2];
  vector<int> v[2];
  vector<pair<int, int> > seg[2];
  vector<int> lazy[2];
  vector<int> seg2[2];
  int cur, l, r, val, Idx;
  pair<int, int> tmp;
  inline void fix(bool b, int idx) {
    seg[cur][idx].first += lazy[cur][idx];
    if (b)
      lazy[cur][(idx << 1)] += lazy[cur][idx],
          lazy[cur][(idx << 1) + 1] += lazy[cur][idx];
    lazy[cur][idx] = 0;
  }
  pair<int, int> getmin(int s, int e, int idx) {
    fix((s != e), idx);
    if (s > r || e < l) return make_pair(2000000000, 2000000000);
    if (s >= l && e <= r) return seg[cur][idx];
    return min(getmin(s, ((s + e) >> 1), (idx << 1)),
               getmin(((s + e) >> 1) + 1, e, (idx << 1) + 1));
  }
  pair<int, int> update(int s, int e, int idx) {
    fix((s != e), idx);
    if (s > r || e < l) return seg[cur][idx];
    if (s >= l && e <= r) {
      lazy[cur][idx] += val;
      fix((s != e), idx);
      return seg[cur][idx];
    }
    return seg[cur][idx] = min(update(s, ((s + e) >> 1), (idx << 1)),
                               update(((s + e) >> 1) + 1, e, (idx << 1) + 1));
  }
  int getsum(int s, int e, int idx) {
    if (s > r || e < l) return 0;
    if (s >= l && e <= r) return seg2[cur][idx];
    return getsum(s, ((s + e) >> 1), (idx << 1)) +
           getsum(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  }
  int update2(int s, int e, int idx) {
    if (s > Idx || e < Idx) return seg2[cur][idx];
    if (s == e) {
      seg2[cur][idx] += val;
      return seg2[cur][idx];
    }
    return seg2[cur][idx] = update2(s, ((s + e) >> 1), (idx << 1)) +
                            update2(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  }
  int get(int i, int x) {
    cur = i;
    i = upper_bound(v[cur].begin(), v[cur].end(), x) - v[cur].begin() - 1;
    if (i < 0) return -1;
    l = 0, r = i;
    return getsum(0, (int)v[cur].size() - 1, 1);
  }
  void remove(int i) {
    cur = 0;
    l = upper_bound(v[0].begin(), v[0].end(), a[i]) - v[0].begin();
    r = lower_bound(v[0].begin(), v[0].end(), c[i]) - v[0].begin() - 1;
    val = -1;
    if (l <= r) update(0, (int)v[0].size() - 1, 1);
    r++;
    l = r;
    Idx = r;
    update2(0, (int)v[0].size() - 1, 1);
    cur = 1;
    l = upper_bound(v[1].begin(), v[1].end(), b[i]) - v[1].begin();
    r = lower_bound(v[1].begin(), v[1].end(), d[i]) - v[1].begin() - 1;
    val = -1;
    if (l <= r) update(0, (int)v[1].size() - 1, 1);
    r++;
    l = r;
    Idx = r;
    update2(0, (int)v[1].size() - 1, 1);
    st[0].erase(st[0].find(make_pair(c[i], i)));
    st[1].erase(st[1].find(make_pair(d[i], i)));
  }
  int get1(int i) {
    cur = i;
    it = st[i].begin();
    l = it->first;
    it = st[i].end();
    it--;
    while (last[i] >= 0 && v[i][last[i]] >= it->first) last[i]--;
    if (last[i] < 0) return -1;
    r = last[i];
    l = lower_bound(v[i].begin(), v[i].end(), l) - v[i].begin();
    if (r < l) return -1;
    tmp = getmin(0, (int)v[i].size() - 1, 1);
    if (tmp.first != 0) return -1;
    return v[i][tmp.second];
  }
};
int sum1[N], sum2[N], sum3[N], sum4[N];
bool A;
void build(int s, int e, int idx, S &cur) {
  if (A == 0)
    cur.lazy[0][idx] = 0;
  else
    cur.lazy[1][idx] = 0;
  if (s == e) {
    if (A == 0) cur.seg[0][idx] = make_pair(sum1[s], s);
    if (A == 1) cur.seg[1][idx] = make_pair(sum2[s], s);
    return;
  }
  build(s, ((s + e) >> 1), (idx << 1), cur);
  build(((s + e) >> 1) + 1, e, (idx << 1) + 1, cur);
  if (A == 0)
    cur.seg[0][idx] = min(cur.seg[0][(idx << 1)], cur.seg[0][(idx << 1) + 1]);
  if (A == 1)
    cur.seg[1][idx] = min(cur.seg[1][(idx << 1)], cur.seg[1][(idx << 1) + 1]);
  return;
}
int build2(int s, int e, int idx, S &cur) {
  if (s == e) return cur.seg2[A][idx] = (A == 0 ? sum3[s] : sum4[s]);
  return cur.seg2[A][idx] = build2(s, ((s + e) >> 1), (idx << 1), cur) +
                            build2(((s + e) >> 1) + 1, e, (idx << 1) + 1, cur);
}
void make(vector<int> &arr, S &tmp) {
  tmp.v[0].clear();
  tmp.v[1].clear();
  tmp.st[0].clear();
  tmp.st[1].clear();
  for (int i = 0; i < (int)arr.size(); i++) {
    tmp.v[0].push_back(c[arr[i]]);
    tmp.v[1].push_back(d[arr[i]]);
    tmp.st[0].insert(make_pair(c[arr[i]], arr[i]));
    tmp.st[1].insert(make_pair(d[arr[i]], arr[i]));
    sum1[i] = sum2[i] = sum3[i] = sum4[i] = 0;
  }
  for (int i = 0; i < 2; i++) {
    sort(tmp.v[i].begin(), tmp.v[i].end());
    tmp.v[i].resize(unique(tmp.v[i].begin(), tmp.v[i].end()) -
                    tmp.v[i].begin());
    tmp.last[i] = (int)tmp.v[i].size() - 1;
  }
  for (int i = 0; i < (int)arr.size(); i++) {
    sum1[upper_bound(tmp.v[0].begin(), tmp.v[0].end(), a[arr[i]]) -
         tmp.v[0].begin()]++;
    sum1[lower_bound(tmp.v[0].begin(), tmp.v[0].end(), c[arr[i]]) -
         tmp.v[0].begin()]--;
    sum2[upper_bound(tmp.v[1].begin(), tmp.v[1].end(), b[arr[i]]) -
         tmp.v[1].begin()]++;
    sum2[lower_bound(tmp.v[1].begin(), tmp.v[1].end(), d[arr[i]]) -
         tmp.v[1].begin()]--;
    sum3[lower_bound(tmp.v[0].begin(), tmp.v[0].end(), c[arr[i]]) -
         tmp.v[0].begin()]++;
    sum4[lower_bound(tmp.v[1].begin(), tmp.v[1].end(), d[arr[i]]) -
         tmp.v[1].begin()]++;
  }
  for (int i = 1; i < (int)tmp.v[0].size(); i++) sum1[i] += sum1[i - 1];
  for (int i = 1; i < (int)tmp.v[1].size(); i++) sum2[i] += sum2[i - 1];
  if ((int)4 * (int)tmp.v[0].size() > (int)tmp.seg[0].size())
    tmp.seg[0].resize((int)4 * (int)tmp.v[0].size());
  if ((int)4 * (int)tmp.v[0].size() > (int)tmp.seg2[0].size())
    tmp.seg2[0].resize((int)4 * (int)tmp.v[0].size());
  if ((int)4 * (int)tmp.v[0].size() > (int)tmp.lazy[0].size())
    tmp.lazy[0].resize((int)4 * (int)tmp.v[0].size(), 0);
  if ((int)4 * (int)tmp.v[1].size() > (int)tmp.seg[1].size())
    tmp.seg[1].resize((int)4 * (int)tmp.v[1].size());
  if ((int)4 * (int)tmp.v[1].size() > (int)tmp.seg2[1].size())
    tmp.seg2[1].resize((int)4 * (int)tmp.v[1].size());
  if ((int)4 * (int)tmp.v[1].size() > (int)tmp.lazy[1].size())
    tmp.lazy[1].resize((int)4 * (int)tmp.v[1].size(), 0);
  A = 0;
  build(0, (int)tmp.v[0].size() - 1, 1, tmp);
  build2(0, (int)tmp.v[0].size() - 1, 1, tmp);
  A = 1;
  build(0, (int)tmp.v[1].size() - 1, 1, tmp);
  build2(0, (int)tmp.v[1].size() - 1, 1, tmp);
  arr.clear();
}
vector<int> arr[N];
int cnt = 0;
bool solve(S &cur) {
  int all = (int)cur.st[0].size();
  if (all == 1) {
    return true;
  }
  int now = cnt++;
  int A = 0;
  int x = cur.get1(0);
  if (x == -1) {
    A = 1;
    x = cur.get1(1);
  }
  if (x == -1) return false;
  int b = cur.get(A, x);
  if (b < all - b) {
    while ((int)cur.st[A].size() > 1) {
      it = cur.st[A].begin();
      if (it->first > x) break;
      arr[now].push_back(it->second);
      cur.remove(it->second);
    }
  } else {
    while ((int)cur.st[A].size() > 1) {
      it = cur.st[A].end();
      if (it == cur.st[A].begin()) break;
      it--;
      if (it->first <= x) break;
      arr[now].push_back(it->second);
      cur.remove(it->second);
    }
  }
  if (!solve(cur)) return false;
  if ((int)arr[now].size() == 1) return true;
  make(arr[now], cur);
  return solve(cur);
}
S tmp;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    arr.push_back(i);
  }
  make(arr, tmp);
  if (solve(tmp))
    puts("YES");
  else
    puts("NO");
  return 0;
}
