#include <bits/stdc++.h>
using namespace std;
map<int, bool> m;
map<int, int> m1;
int t[1600004], lazy[1600005];
void push(int v) {
  t[v * 2] = min(t[v * 2], lazy[v]);
  lazy[v * 2] = min(lazy[v * 2], lazy[v]);
  t[v * 2 + 1] = min(t[v * 2 + 1], lazy[v]);
  lazy[v * 2 + 1] = min(lazy[v * 2 + 1], lazy[v]);
  lazy[v] = 1000000007;
}
void update(int v, int tl, int tr, int l, int r, int addend) {
  if (l > r) return;
  if (l == tl && tr == r) {
    t[v] = min(t[v], addend);
    lazy[v] = min(lazy[v], addend);
  } else {
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(r, tm), addend);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, addend);
    t[v] = min(t[v * 2], t[v * 2 + 1]);
  }
}
int query(int v, int tl, int tr, int l, int r) {
  if (l > r) return 1000000007;
  if (l <= tl && tr <= r) return t[v];
  push(v);
  int tm = (tl + tr) / 2;
  return min(query(v * 2, tl, tm, l, min(r, tm)),
             query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int n, x1[100005], yy1[100005], x2[100005], y2[100005], i, l;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  m.clear();
  for (i = 0; i < n; i++) {
    cin >> x1[i] >> x2[i] >> yy1[i] >> y2[i];
    if (!m[x1[i]]) {
      v.push_back(x1[i]);
      m[x1[i]] = 1;
    }
    if (!m[x2[i]]) {
      v.push_back(x2[i]);
      m[x2[i]] = 1;
    }
    if (!m[yy1[i]]) {
      v.push_back(yy1[i]);
      m[yy1[i]] = 1;
    }
    if (!m[y2[i]]) {
      v.push_back(y2[i]);
      m[y2[i]] = 1;
    }
  }
  sort(v.begin(), v.end());
  l = v.size();
  for (i = 0; i < l; i++) {
    m1[v[i]] = i;
  }
  for (i = 0; i < n; i++) {
    x1[i] = m1[x1[i]];
    x2[i] = m1[x2[i]];
    yy1[i] = m1[yy1[i]];
    y2[i] = m1[y2[i]];
  }
  for (i = 0; i <= 4 * l; i++) {
    t[i] = 1000000007;
    lazy[i] = 1000000007;
  }
  for (i = 0; i < n; i++) {
    update(1, 0, l - 1, min(x1[i], x2[i]), max(x1[i], x2[i]),
           max(yy1[i], y2[i]));
  }
  for (i = 0; i < n; i++) {
    int val = query(1, 0, l - 1, min(x1[i], x2[i]), max(x1[i], x2[i]));
    if (val < min(yy1[i], y2[i])) {
      cout << "NO\n";
      return 0;
    }
  }
  for (i = 0; i <= 4 * l; i++) {
    t[i] = 1000000007;
    lazy[i] = 1000000007;
  }
  for (i = 0; i < n; i++) {
    update(1, 0, l - 1, min(yy1[i], y2[i]), max(yy1[i], y2[i]),
           max(x1[i], x2[i]));
  }
  for (i = 0; i < n; i++) {
    int val = query(1, 0, l - 1, min(yy1[i], y2[i]), max(yy1[i], y2[i]));
    if (val < min(x1[i], x2[i])) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
