#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int N;
unsigned long long val[MAX], s[MAX];
struct node {
  int p, id, k;
  bool operator<(const node &rhs) const {
    return p < rhs.p || (p == rhs.p && k < rhs.k);
  }
} a[MAX], b[MAX];
bool judge() {
  for (int i = 1; i <= N; i++)
    if (s[i] > 0) return false;
  return true;
}
int main() {
  srand(time(0));
  scanf("%d", &N);
  int tot = 0;
  for (int i = 1; i <= N; i++) {
    val[i] = (unsigned long long)rand() << 31 | rand();
    int as, ae, bs, be;
    scanf("%d%d%d%d", &as, &ae, &bs, &be);
    a[++tot] = node{as, i, 0};
    a[++tot] = node{ae, i, 1};
    tot -= 2;
    b[++tot] = node{be, i, 1};
    b[++tot] = node{bs, i, 0};
  }
  sort(a + 1, a + 1 + tot);
  sort(b + 1, b + 1 + tot);
  unsigned long long Xor = 0;
  for (int i = 1; i <= tot; i++) {
    if (a[i].k)
      Xor ^= val[a[i].id];
    else
      s[a[i].id] ^= Xor;
  }
  Xor = 0;
  for (int i = 1; i <= tot; i++) {
    if (b[i].k)
      Xor ^= val[b[i].id];
    else
      s[b[i].id] ^= Xor;
  }
  Xor = 0;
  for (int i = tot; i >= 1; i--) {
    if (!a[i].k)
      Xor ^= val[a[i].id];
    else
      s[a[i].id] ^= Xor;
  }
  Xor = 0;
  for (int i = tot; i >= 1; i--) {
    if (!b[i].k)
      Xor ^= val[b[i].id];
    else
      s[b[i].id] ^= Xor;
  }
  printf("%s\n", judge() ? "YES" : "NO");
  return 0;
}
