#include <bits/stdc++.h>
using namespace std;
const int N = 400100;
int n, a[N], b[N], c[N], d[N], tree[4 * N];
vector<int> v;
vector<pair<int, int> > x;
vector<pair<int, int> > y;
void build(int root, int rl, int rr) {
  if (rl == rr) {
    tree[root] = -1;
  } else {
    int rm = (rl + rr) / 2;
    build(root * 2 + 1, rl, rm);
    build(root * 2 + 2, rm + 1, rr);
    tree[root] = -1;
  }
}
void update(int root, int rl, int rr, int at, int by) {
  if (rl == rr) {
    tree[root] = max(tree[root], by);
    return;
  }
  int rm = (rl + rr) / 2;
  if (at <= rm) {
    update(root * 2 + 1, rl, rm, at, by);
    tree[root] = max(tree[root * 2 + 1], tree[root * 2 + 2]);
  } else {
    update(root * 2 + 2, rm + 1, rr, at, by);
    tree[root] = max(tree[root * 2 + 1], tree[root * 2 + 2]);
  }
}
int query(int root, int rl, int rr, int l, int r) {
  if (l > r) {
    return -1;
  }
  if (l == rl && r == rr) {
    return tree[root];
  }
  int rm = (rl + rr) / 2;
  return max(query(root * 2 + 1, rl, rm, l, min(r, rm)),
             query(root * 2 + 2, rm + 1, rr, max(l, rm + 1), r));
}
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]);
    v.push_back(a[i]);
    v.push_back(b[i]);
    v.push_back(c[i]);
    v.push_back(d[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    b[i] = lower_bound(v.begin(), v.end(), b[i]) - v.begin();
    c[i] = lower_bound(v.begin(), v.end(), c[i]) - v.begin();
    d[i] = lower_bound(v.begin(), v.end(), d[i]) - v.begin();
  }
  for (int it = 0; it < 2; it++) {
    for (int i = 0; i < n; i++) {
      x.push_back(make_pair(b[i], i));
      y.push_back(make_pair(a[i], i));
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    build(0, 0, v.size() - 1);
    for (int i = x.size() - 1, j = y.size() - 1; i >= 0; i--) {
      while (j >= 0 && y[j].first > x[i].first) {
        int id = y[j].second;
        update(0, 0, v.size() - 1, c[id], d[id]);
        j--;
      }
      int id = x[i].second;
      if (query(0, 0, v.size() - 1, 0, d[id]) >= c[id]) {
        puts("NO");
        exit(0);
      }
    }
    x.clear();
    y.clear();
    for (int i = 0; i < n; i++) {
      swap(a[i], c[i]);
      swap(b[i], d[i]);
    }
  }
  puts("YES");
  return 0;
}
