#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto &x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
inline int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % MOD); }
inline int binpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b /= 2;
  }
  return res;
}
inline int inv(int a) { return binpow(a, MOD - 2); }
int gcd(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  int x1, y1;
  int d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Hash {
  long long MOD, r, hash;
  Hash() { hash = 1; }
  void add(long long i) { hash = hash * (r + i) % MOD; }
  long long get() { return hash; }
} hash1, hash2;
struct Line {
  long long l, r, id;
};
bool sortByL(Line a, Line b) { return a.l < b.l; }
bool sortByR(Line a, Line b) { return a.r < b.r; }
void process(vector<Line> v1, vector<long long> &a, vector<long long> &b) {
  long long n = v1.size();
  vector<Line> v2 = v1;
  sort((v1).begin(), (v1).end(), sortByL);
  sort((v2).begin(), (v2).end(), sortByR);
  hash1.hash = 1;
  hash2.hash = 1;
  for (long long i = 0, j = 0; i < n; ++i) {
    while (j < n && v2[j].r < v1[i].l) {
      hash1.add(v2[j].id);
      hash2.add(v2[j].id);
      j++;
    }
    long long id = v1[i].id;
    a[id] = (a[id] * hash1.get()) % hash1.MOD;
    b[id] = (b[id] * hash2.get()) % hash2.MOD;
  }
  hash1.hash = 1;
  hash2.hash = 1;
  for (long long i = n - 1, j = n - 1; i >= 0; --i) {
    while (j >= 0 && v1[j].l > v2[i].r) {
      hash1.add(v1[j].id);
      hash2.add(v1[j].id);
      j--;
    }
    long long id = v2[i].id;
    a[id] = (a[id] * hash1.get()) % hash1.MOD;
    b[id] = (b[id] * hash2.get()) % hash2.MOD;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<Line> a(n), b(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].l >> a[i].r >> b[i].l >> b[i].r;
    a[i].id = i, b[i].id = i;
  }
  vector<long long> hashA[2], hashB[2];
  hashA[0] = hashA[1] = hashB[0] = hashB[1] = vector<long long>(n, 1);
  long long p1 = 1e9 + 9, p2 = 1e9 + 7;
  long long r1 = uniform_int_distribution<long long>(0, p1 - 1)(rng);
  long long r2 = uniform_int_distribution<long long>(0, p2 - 1)(rng);
  hash1.MOD = p1, hash1.r = r1;
  hash2.MOD = p2, hash2.r = r2;
  process(a, hashA[0], hashA[1]);
  process(b, hashB[0], hashB[1]);
  bool flag = true;
  for (long long i = 0; i < n; ++i) {
    if ((hashA[0][i] != hashB[0][i]) || (hashA[1][i] != hashB[1][i]))
      flag = false;
  }
  flag ? cout << "YES\n" : cout << "NO\n";
  return 0;
}
