#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1299709;
const long long MOD = 1e9 + 7;
bitset<MAX> f;
long long rev(long long num) {
  long long ans = 1;
  long long x = num;
  long long cur = MOD - 2;
  for (int i = 0; i < 30; ++i) {
    if ((1 << i) & cur) {
      ans *= x;
      ans %= MOD;
    }
    x *= x;
    x %= MOD;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int num = 0;
  map<int, int> mp;
  for (int i = 2; i < MAX + 1; ++i) {
    if (!f[i]) {
      long long cur = 1ll * i * i;
      while (cur < MAX) {
        f[cur] = 1;
        cur += i;
      }
      mp[num++] = i;
    }
  }
  int n;
  cin >> n;
  pair<int, pair<int, int> > a[n], b[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second.first >> b[i].first >> b[i].second.first;
    a[i].second.second = b[i].second.second = i;
  }
  sort(a, a + n);
  sort(b, b + n);
  long long cur = 1;
  vector<int> temp(n);
  vector<long long> t(n), t1(n);
  t[0] = mp[a[0].second.second];
  t1[0] = mp[b[0].second.second];
  for (int i = 1; i < n; ++i) {
    t[i] = t[i - 1] * mp[a[i].second.second] % MOD;
    t1[i] = t1[i - 1] * mp[b[i].second.second] % MOD;
  }
  set<pair<int, int> > rem;
  for (int i = 0; i < n; ++i) {
    while (rem.size() > 0 && rem.begin()->first < a[i].first) {
      cur *= rev(mp[rem.begin()->second]);
      cur %= MOD;
      rem.erase(rem.begin());
    }
    int pos = upper_bound(a, a + n,
                          make_pair(a[i].second.first,
                                    make_pair(1000000001, 1000000001))) -
              a - 1;
    long long newcur = t[pos];
    if (i > 0) {
      newcur *= rev(t[i - 1]);
      newcur %= MOD;
    }
    temp[a[i].second.second] = newcur * cur % MOD;
    cur *= mp[a[i].second.second];
    cur %= MOD;
    rem.insert({a[i].second.first, a[i].second.second});
  }
  rem.clear();
  cur = 1;
  for (int i = 0; i < n; ++i) {
    while (rem.size() > 0 && rem.begin()->first < b[i].first) {
      cur *= rev(mp[rem.begin()->second]);
      cur %= MOD;
      rem.erase(rem.begin());
    }
    int pos = upper_bound(b, b + n,
                          make_pair(b[i].second.first,
                                    make_pair(1000000001, 1000000001))) -
              b - 1;
    long long newcur = t1[pos];
    if (i > 0) {
      newcur *= rev(t1[i - 1]);
      newcur %= MOD;
    }
    if (temp[b[i].second.second] != newcur * cur % MOD) {
      cout << "NO\n";
      return 0;
    }
    cur *= mp[b[i].second.second];
    cur %= MOD;
    rem.insert({b[i].second.first, b[i].second.second});
  }
  cout << "YES\n";
  return 0;
}
