#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
long long n;
vector<long long> coef;
long long licz(vector<pair<long long, long long> > t) {
  vector<long long> p(n), k(n);
  for (long long i = (0); i <= ((long long)(n)-1); i++) p[i] = k[i] = i;
  sort((p).begin(), (p).end(),
       [&](long long a, long long b) { return t[a].first < t[b].first; });
  sort((k).begin(), (k).end(),
       [&](long long a, long long b) { return t[a].second < t[b].second; });
  long long sum = 0;
  long long hash = 0;
  long long j = 0;
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    while (j < n && t[p[j]].first < t[k[i]].second) {
      sum += coef[p[j]];
      j++;
    }
    hash += sum * coef[k[i]];
    sum -= coef[k[i]];
  }
  return hash;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  srand(time(0));
  cin >> n;
  coef.resize(n);
  vector<pair<long long, long long> > p(n), s(n);
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    coef[i] = ((rand() * 1ll) << 32) + ((rand() * 1ll) << 16) + rand();
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    cin >> s[i].first >> s[i].second;
    s[i].first--;
  }
  if (licz(p) == licz(s)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
