#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int N = 1e5 + 5;
struct lect {
  int sa, ea, sb, eb, id;
};
int n, fen[2 * N];
lect lec[N];
void input() {
  vector<int> ta, tb;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> lec[i].sa >> lec[i].ea >> lec[i].sb >> lec[i].eb;
    lec[i].id = i;
    ta.emplace_back(lec[i].sa);
    ta.emplace_back(lec[i].ea);
    tb.emplace_back(lec[i].sb);
    tb.emplace_back(lec[i].eb);
  }
  sort(ta.begin(), ta.end());
  sort(tb.begin(), tb.end());
  ta.resize(unique(ta.begin(), ta.end()) - ta.begin());
  tb.resize(unique(tb.begin(), tb.end()) - tb.begin());
  for (int i = 1; i <= n; ++i) {
    lec[i].sa = lower_bound(ta.begin(), ta.end(), lec[i].sa) - ta.begin() + 1;
    lec[i].ea = lower_bound(ta.begin(), ta.end(), lec[i].ea) - ta.begin() + 1;
    lec[i].sb = lower_bound(tb.begin(), tb.end(), lec[i].sb) - tb.begin() + 1;
    lec[i].eb = lower_bound(tb.begin(), tb.end(), lec[i].eb) - tb.begin() + 1;
  }
}
void resetbit() {
  for (int i = 1; i <= 2 * n; ++i) fen[i] = 0;
}
void update(int p, int val) {
  for (; p <= 2 * n; p += p & -p) fen[p] += val;
}
int sum(int p) {
  int res = 0;
  for (; p; p -= p & -p) res += fen[p];
  return res;
}
bool check() {
  sort(lec + 1, lec + 1 + n, [](const lect &x, const lect &y) {
    return make_pair(x.sa, x.ea) < make_pair(y.sa, y.ea);
  });
  resetbit();
  set<ii> st;
  for (int i = 1; i <= n; ++i) {
    while (!st.empty() && st.begin()->first < lec[i].sa) {
      int j = st.begin()->second;
      st.erase(st.begin());
      update(lec[j].sb, +1);
    }
    st.emplace(lec[i].ea, i);
    if (sum(lec[i].eb) - sum(lec[i].sb - 1) > 0) return false;
  }
  sort(lec + 1, lec + 1 + n, [](const lect &x, const lect &y) {
    return make_pair(x.ea, x.sa) > make_pair(y.ea, y.sa);
  });
  resetbit();
  set<ii, greater<ii>> st2;
  for (int i = 1; i <= n; ++i) {
    while (!st2.empty() && st2.begin()->first > lec[i].ea) {
      int j = st2.begin()->second;
      st2.erase(st2.begin());
      update(lec[j].sb, +1);
    }
    st2.emplace(lec[i].sa, i);
    if (sum(lec[i].eb) - sum(lec[i].sb - 1) > 0) return false;
  }
  return true;
}
void solve() {
  if (!check()) {
    cout << "NO";
    return;
  }
  for (int i = 1; i <= n; ++i) {
    swap(lec[i].sa, lec[i].sb);
    swap(lec[i].ea, lec[i].eb);
  }
  if (!check()) {
    cout << "NO";
    return;
  }
  cout << "YES";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  input();
  solve();
  return 0;
}
