#include <bits/stdc++.h>
using namespace std;
inline unsigned long long read() {
  char ch = getchar();
  unsigned long long nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  unsigned long long ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
struct Node {
  unsigned long long id, x, d;
  Node() {}
  Node(unsigned long long id, unsigned long long x, unsigned long long d)
      : id(id), x(x), d(d) {}
};
Node a1[100005 * 2], a2[100005 * 2];
unsigned long long val[100005];
unsigned long long s[100005];
bool cmp(Node x, Node y) {
  if (x.d != y.d) return x.d < y.d;
  return x.x > y.x;
}
signed main() {
  unsigned long long n = read();
  for (unsigned long long i = 1; i <= n; i++) {
    unsigned long long c = read(), d = read(), e = read(), f = read();
    a1[2 * i - 1] = Node(i, 1, c);
    a1[2 * i] = Node(i, 0, d);
    a2[2 * i - 1] = Node(i, 1, e);
    a2[2 * i] = Node(i, 0, f);
  }
  sort(a1 + 1, a1 + n + n + 1, cmp);
  sort(a2 + 1, a2 + n + n + 1, cmp);
  mt19937 rng(time(NULL));
  for (unsigned long long i = 1; i <= n; i++) val[i] = rng() << 31 | rng();
  unsigned long long sum = 0;
  for (unsigned long long i = 1; i <= n + n; i++) {
    if (a1[i].x == 0)
      sum ^= val[a1[i].id];
    else
      s[a1[i].id] ^= sum;
  }
  sum = 0;
  for (unsigned long long i = n + n; i >= 1; i--) {
    if (a1[i].x == 1)
      sum ^= val[a1[i].id];
    else
      s[a1[i].id] ^= sum;
  }
  sum = 0;
  for (unsigned long long i = 1; i <= n + n; i++) {
    if (a2[i].x == 0)
      sum ^= val[a2[i].id];
    else
      s[a2[i].id] ^= sum;
  }
  sum = 0;
  for (unsigned long long i = n + n; i >= 1; i--) {
    if (a2[i].x == 1)
      sum ^= val[a2[i].id];
    else
      s[a2[i].id] ^= sum;
  }
  for (unsigned long long i = 1; i <= n; i++) {
    if (s[i] != 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
