#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int inf = 1e9;
int mod = 1e9 + 7;
struct ST {
  int maxi, mini;
  ST(int maxi = 0, int mini = 0) : maxi(maxi), mini(mini) {}
};
ST operator+(const ST &A, const ST &B) {
  int M = max(A.maxi, B.maxi);
  int m = min(A.mini, B.mini);
  return ST(M, m);
}
struct segtree {
  vector<ST> tree;
  vector<int> A, B;
  segtree(int n = N) {
    tree.resize(4 * n);
    A.resize(n);
    B.resize(n);
  }
  void build(int node, int start, int end) {
    if (start == end) {
      tree[node] = ST(A[start], B[start]);
    } else {
      int mid = (start + end) >> 1;
      build(2 * node, start, mid);
      build(2 * node + 1, mid + 1, end);
      tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
  }
  ST query(int node, int start, int end, int l, int r) {
    if (start >= l && end <= r) return tree[node];
    int mid = (start + end) >> 1;
    if (mid >= r) return query(2 * node, start, mid, l, r);
    if (mid < l) return query(2 * node + 1, mid + 1, end, l, r);
    ST P1 = query(2 * node, start, mid, l, r);
    ST P2 = query(2 * node + 1, mid + 1, end, l, r);
    return P1 + P2;
  }
};
int n;
int sa[N], ea[N], sb[N], eb[N];
int id[N];
bool solve() {
  segtree T(n);
  sort(id, id + n, [&](int x, int y) { return sa[x] < sa[y]; });
  map<int, int> M;
  for (int i = 0; i < n; i++) {
    T.A[i] = sb[id[i]];
    T.B[i] = eb[id[i]];
    if (M.find(sa[id[i]]) == M.end()) {
      M[sa[id[i]]] = i;
    }
  }
  T.build(1, 0, n - 1);
  for (int i = 0; i < n; i++) {
    int l = i, r = n - 1;
    int u = -1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (sa[id[mid]] <= ea[id[i]]) {
        u = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    if (u != -1) {
      int M = T.query(1, 0, n - 1, i, u).maxi;
      int m = T.query(1, 0, n - 1, i, u).mini;
      if (M > eb[id[i]]) {
        return false;
      }
      if (m < sb[id[i]]) {
        return false;
      }
    }
  }
  return true;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> sa[i] >> ea[i] >> sb[i] >> eb[i];
    id[i] = i;
  }
  if (!solve()) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    swap(sa[i], sb[i]);
    swap(ea[i], eb[i]);
    id[i] = i;
  }
  if (!solve()) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return 0;
}
