#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
constexpr ll mod = 1e9 + 7;
constexpr int N = 100010;
constexpr int INF = 0x3f3f3f3f;
struct node1 {
  int sa, ea, sb, eb;
  node1() {}
  node1(int sa, int ea, int sb, int eb) : sa(sa), ea(ea), sb(sb), eb(eb) {}
  bool operator<(const node1& o) const { return sa < o.sa; }
  bool operator>(const node1& o) const { return sa > o.sa; }
} q[N];
int n;
struct node2 {
  int l, r;
  int mn, mx;
} tree[N << 2];
void pushup(int u) {
  tree[u].mn = min(tree[u << 1].mn, tree[u << 1 | 1].mn);
  tree[u].mx = max(tree[u << 1].mx, tree[u << 1 | 1].mx);
}
void build(int u, int l, int r) {
  tree[u] = {l, r, INF, -INF};
  if (l == r) {
    tree[u].mn = q[l].eb;
    tree[u].mx = q[l].sb;
    return;
  }
  int mid = l + r >> 1;
  build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
  pushup(u);
}
int qmin(int u, int l, int r) {
  if (tree[u].l >= l && tree[u].r <= r) return tree[u].mn;
  int mid = tree[u].l + tree[u].r >> 1;
  int v = INF;
  if (l <= mid) v = min(v, qmin(u << 1, l, r));
  if (r > mid) v = min(v, qmin(u << 1 | 1, l, r));
  return v;
}
int qmax(int u, int l, int r) {
  if (tree[u].l >= l && tree[u].r <= r) return tree[u].mx;
  int mid = tree[u].l + tree[u].r >> 1;
  int v = -INF;
  if (l <= mid) v = max(v, qmax(u << 1, l, r));
  if (r > mid) v = max(v, qmax(u << 1 | 1, l, r));
  return v;
}
bool solve() {
  sort(q + 1, q + 1 + n);
  build(1, 1, n);
  for (int i = 1; i < n; i++) {
    int pos = upper_bound(q + 1, q + 1 + n, node1(q[i].ea, 0, 0, 0)) - q;
    pos--;
    if (qmin(1, i + 1, pos) < q[i].sb || qmax(1, i + 1, pos) > q[i].eb)
      return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++)
      cin >> q[i].sa >> q[i].ea >> q[i].sb >> q[i].eb;
    bool ok = 1;
    ok &= solve();
    for (int i = 1; i <= n; i++) swap(q[i].sa, q[i].sb), swap(q[i].ea, q[i].eb);
    ok &= solve();
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
