#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int sa[N], ea[N], sb[N], eb[N];
struct Event {
  int times, st, ed, type;
  Event() {}
  Event(int times_, int st_, int ed_, int type_)
      : times(times_), st(st_), ed(ed_), type(type_) {}
  bool operator<(const Event& rhs) const {
    return times != rhs.times ? times < rhs.times : type < rhs.type;
  }
} event[N * 2];
bool check(int sa[], int ea[], int sb[], int eb[]) {
  for (int i = 0; i < n; ++i) {
    event[i] = Event(sa[i], sb[i], eb[i], 1);
    event[i + n] = Event(ea[i] + 1, sb[i], eb[i], -1);
  }
  sort(event, event + n * 2);
  multiset<int> st, ed;
  for (int i = 0; i < n * 2; ++i) {
    int a = event[i].st, b = event[i].ed, type = event[i].type;
    if (type == -1) {
      st.erase(st.find(a));
      ed.erase(ed.find(b));
    } else {
      if (!st.empty()) {
        int maxSt = *st.rbegin();
        int minEd = *ed.begin();
        if (b < maxSt || a > minEd) return false;
      }
      st.insert(a);
      ed.insert(b);
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> sa[i] >> ea[i] >> sb[i] >> eb[i];
  if (check(sa, ea, sb, eb) && check(sb, eb, sa, ea))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
