#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int a[N], b[N], c[N], d[N];
unsigned long long sa[N], sb[N], sc[N], sd[N], se[N], sf[N];
struct cla {
  int a, b, c;
} e[N];
inline unsigned long long getrand() {
  unsigned long long f = 1;
  return f * rand() * rand() * rand() * rand() * rand() * rand() * rand();
}
inline bool cmp(cla a, cla b) {
  if (a.b == b.b) return a.a < b.a;
  return a.b < b.b;
}
int main() {
  int n;
  srand(114514);
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
  for (int i = 1; i <= n; i++)
    sa[i] = getrand(), sb[i] = getrand(), sc[i] = getrand();
  for (int i = 1; i <= n; i++) {
    e[i].a = 0, e[i].b = a[i], e[i].c = i;
    e[i + n].a = 1, e[i + n].b = b[i], e[i + n].c = i;
  }
  sort(e + 1, e + 2 * n + 1, cmp);
  unsigned long long oa = 0, ob = 0, oc = 0, od = 0, oe = 0, of = 0;
  for (int i = 1; i <= n; i++) od ^= sa[i], oe ^= sb[i], of ^= sc[i];
  for (int i = 1; i <= 2 * n; i++) {
    int x = i;
    while (e[x + 1].a == e[i].a && e[x + 1].b == e[i].b) x++;
    if (e[i].a == 0) {
      for (int c = i; c <= x; c++) {
        int t = e[c].c;
        sd[t] ^= oa, se[t] ^= ob, sf[t] ^= oc;
        od ^= sa[t], oe ^= sb[t], of ^= sc[t];
      }
      i = x;
    }
    if (e[i].a == 1) {
      for (int c = i; c <= x; c++) {
        int t = e[c].c;
        sd[t] ^= od, se[t] ^= oe, sf[t] ^= of;
        oa ^= sa[t], ob ^= sb[t], oc ^= sc[t];
      }
      i = x;
    }
  }
  oa = 0, ob = 0, oc = 0, od = 0, oe = 0, of = 0;
  for (int i = 1; i <= n; i++) od ^= sa[i], oe ^= sb[i], of ^= sc[i];
  for (int i = 1; i <= n; i++) {
    e[i].a = 0, e[i].b = c[i], e[i].c = i;
    e[i + n].a = 1, e[i + n].b = d[i], e[i + n].c = i;
  }
  sort(e + 1, e + 2 * n + 1, cmp);
  for (int i = 1; i <= 2 * n; i++) {
    int x = i;
    while (e[x + 1].a == e[i].a && e[x + 1].b == e[i].b) x++;
    if (e[i].a == 0) {
      for (int c = i; c <= x; c++) {
        int t = e[c].c;
        sd[t] ^= oa, se[t] ^= ob, sf[t] ^= oc;
        od ^= sa[t], oe ^= sb[t], of ^= sc[t];
      }
      i = x;
    }
    if (e[i].a == 1) {
      for (int c = i; c <= x; c++) {
        int t = e[c].c;
        sd[t] ^= od, se[t] ^= oe, sf[t] ^= of;
        oa ^= sa[t], ob ^= sb[t], oc ^= sc[t];
      }
      i = x;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (sd[i] || se[i] || sf[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
