#include <bits/stdc++.h>
using namespace std;
struct gg {
  int id, sa, ea, sb, eb;
  void input(int i) {
    id = i;
    scanf("%d%d%d%d", &sa, &ea, &sb, &eb);
  }
};
bool cmpsa(gg a, gg b) { return a.sa < b.sa; }
bool cmpea(gg a, gg b) { return a.ea < b.ea; }
bool cmpsb(gg a, gg b) { return a.sb < b.sb; }
bool cmpeb(gg a, gg b) { return a.eb < b.eb; }
int nsa[100010], nea[100010], nsb[100010], neb[100010];
gg a[100010];
const unsigned long long P = 19260817;
unsigned long long pp[100010], sa[100010], ea[100010], sb[100010], eb[100010];
int main() {
  pp[0] = 1;
  for (int i = 1; i <= 100000; i++) pp[i] = pp[i - 1] * P;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) a[i].input(i);
  sort(a + 1, a + 1 + n, cmpsa);
  for (int i = n; i >= 1; i--) {
    nsa[i] = a[i].sa;
    sa[i] = sa[i + 1] + pp[a[i].id];
  }
  sort(a + 1, a + 1 + n, cmpea);
  for (int i = 1; i <= n; i++) {
    nea[i] = a[i].ea;
    ea[i] = ea[i - 1] + pp[a[i].id];
  }
  sort(a + 1, a + 1 + n, cmpsb);
  for (int i = n; i >= 1; i--) {
    nsb[i] = a[i].sb;
    sb[i] = sb[i + 1] + pp[a[i].id];
  }
  sort(a + 1, a + 1 + n, cmpeb);
  for (int i = 1; i <= n; i++) {
    neb[i] = a[i].eb;
    eb[i] = eb[i - 1] + pp[a[i].id];
  }
  for (int i = 1; i <= n; i++) {
    int xa = lower_bound(nea + 1, nea + 1 + n, a[i].sa) - nea - 1;
    int ya = upper_bound(nsa + 1, nsa + 1 + n, a[i].ea) - nsa;
    int xb = lower_bound(neb + 1, neb + 1 + n, a[i].sb) - neb - 1;
    int yb = upper_bound(nsb + 1, nsb + 1 + n, a[i].eb) - nsb;
    if ((ea[xa] + sa[ya]) != (eb[xb] + sb[yb])) return 0 * printf("NO\n");
  }
  printf("YES\n");
}
