#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <const int& MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  static int inv_mod(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
      int q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return x < 0 ? x + m : x;
  }
  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }
  _m_int& operator+=(const _m_int& other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int& operator-=(const _m_int& other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int& operator*=(const _m_int& other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }
  _m_int& operator/=(const _m_int& other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int& a, const _m_int& b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int& a, const _m_int& b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int& a, const _m_int& b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int& a, const _m_int& b) {
    return _m_int(a) /= b;
  }
  _m_int& operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int& operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  friend bool operator==(const _m_int& a, const _m_int& b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int& a, const _m_int& b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int& a, const _m_int& b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int& a, const _m_int& b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int& a, const _m_int& b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int& a, const _m_int& b) {
    return a.val >= b.val;
  }
  _m_int inv() const { return inv_mod(val); }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
  friend ostream& operator<<(ostream& os, const _m_int& m) {
    return os << m.val;
  }
};
template <typename U, typename V>
struct pairnum {
  U u;
  V v;
  pairnum() : u(0), v(0) {}
  pairnum(int64_t val) : u(val), v(val) {}
  pairnum(const U& u_, const V& v_) : u(u_), v(v_) {}
  friend std::ostream& operator<<(std::ostream& out, const pairnum& n) {
    return out << '(' << n.u << ',' << ' ' << n.v << ')';
  }
  friend std::istream& operator>>(std::istream& in, pairnum& n) {
    long long val;
    in >> val;
    n = pairnum(val);
    return in;
  }
  friend bool operator==(const pairnum& a, const pairnum& b) {
    return a.u == b.u && a.v == b.v;
  }
  friend bool operator!=(const pairnum& a, const pairnum& b) {
    return a.u != b.u || a.v != b.v;
  }
  pairnum inv() const { return pairnum(u.inv(), v.inv()); }
  pairnum neg() const { return pairnum(u.neg(), v.neg()); }
  pairnum operator-() const { return pairnum(-u, -v); }
  pairnum operator+() const { return pairnum(+u, +v); }
  pairnum& operator++() {
    ++u, ++v;
    return *this;
  }
  pairnum& operator--() {
    --u, --v;
    return *this;
  }
  pairnum& operator+=(const pairnum& o) {
    u += o.u;
    v += o.v;
    return *this;
  }
  pairnum& operator-=(const pairnum& o) {
    u -= o.u;
    v -= o.v;
    return *this;
  }
  pairnum& operator*=(const pairnum& o) {
    u *= o.u;
    v *= o.v;
    return *this;
  }
  pairnum& operator/=(const pairnum& o) {
    u /= o.u;
    v /= o.v;
    return *this;
  }
  friend pairnum operator++(pairnum& a, int) {
    pairnum r = a;
    ++a;
    return r;
  }
  friend pairnum operator--(pairnum& a, int) {
    pairnum r = a;
    --a;
    return r;
  }
  friend pairnum operator+(const pairnum& a, const pairnum& b) {
    return pairnum(a) += b;
  }
  friend pairnum operator-(const pairnum& a, const pairnum& b) {
    return pairnum(a) -= b;
  }
  friend pairnum operator*(const pairnum& a, const pairnum& b) {
    return pairnum(a) *= b;
  }
  friend pairnum operator/(const pairnum& a, const pairnum& b) {
    return pairnum(a) /= b;
  }
};
const int MOD = 1e9 + 7;
using hsh = pairnum<_m_int<MOD>, _m_int<MOD>>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const hsh BASE(rng(), rng());
const int N = 2e5 + 7;
int n;
hsh pows[N];
pii r[2][N];
vector<pii> getHashes(int z) {
  vector<pii> ev;
  for (int i = 0; i < n; i++) {
    ev.push_back({r[z][i].first * 2, i});
    ev.push_back({r[z][i].second * 2 + 1, i});
  }
  sort(ev.begin(), ev.end());
  vector<pii> res;
  hsh curHsh = 0;
  for (int i = 0; i < 2 * n;) {
    int d = ev[i].first % 2;
    while (i < 2 * n && ev[i].first % 2 == d) {
      if (d) {
        curHsh -= pows[ev[i].second];
      } else {
        curHsh += pows[ev[i].second];
      }
      i++;
    }
    res.push_back({(int)curHsh.u, (int)curHsh.v});
  }
  sort(res.begin(), res.end());
  res.resize(unique(res.begin(), res.end()) - res.begin());
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  pows[0] = 1;
  for (int i = 0; i < n; i++) {
    pows[i + 1] = pows[i] * BASE;
  }
  for (int i = 0; i < N; i++)
    cin >> r[0][i].first >> r[0][i].second >> r[1][i].first >> r[1][i].second;
  if (getHashes(0) == getHashes(1))
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
