#include <bits/stdc++.h>
using namespace std;
struct Seg {
  int sa, ea, sb, eb;
} p[200005];
int cmp(Seg &a, Seg &b) {
  if (a.ea != b.ea)
    return a.ea < b.ea;
  else
    return a.sa < b.sa;
}
int n, mx[4 * 200005], mi[4 * 200005];
void creat(int l, int r, int k) {
  if (l == r) {
    mx[k] = p[l].sb, mi[k] = p[l].eb;
    return;
  }
  int mid = (l + r) / 2;
  creat(l, mid, 2 * k);
  creat(mid + 1, r, 2 * k + 1);
  mx[k] = max(mx[2 * k], mx[2 * k + 1]);
  mi[k] = min(mi[2 * k], mi[2 * k + 1]);
}
int querymin(int l, int r, int al, int ar, int k) {
  if (l == al && r == ar) return mi[k];
  int mid = (l + r) / 2;
  if (ar <= mid)
    return querymin(l, mid, al, ar, 2 * k);
  else if (al > mid)
    return querymin(mid + 1, r, al, ar, 2 * k + 1);
  else
    return min(querymin(l, mid, al, mid, 2 * k),
               querymin(mid + 1, r, mid + 1, ar, 2 * k + 1));
}
int querymax(int l, int r, int al, int ar, int k) {
  if (l == al && r == ar) return mx[k];
  int mid = (l + r) / 2;
  if (ar <= mid)
    return querymax(l, mid, al, ar, 2 * k);
  else if (al > mid)
    return querymax(mid + 1, r, al, ar, 2 * k + 1);
  else
    return max(querymax(l, mid, al, mid, 2 * k),
               querymax(mid + 1, r, mid + 1, ar, 2 * k + 1));
}
int ea[200005];
int solve() {
  std::sort(p + 1, p + 1 + n, cmp);
  creat(1, n, 1);
  for (int i = 1; i <= n; i++) ea[i] = p[i].ea;
  for (int i = 1; i <= n; i++) {
    if (i == 1) continue;
    int left = p[i].sa;
    int ans = lower_bound(ea + 1, ea + i, left) - ea;
    if (ans > i - 1) continue;
    int maxL = querymax(1, n, ans, i - 1, 1);
    int minR = querymin(1, n, ans, i - 1, 1);
    if (minR < p[i].sb || maxL > p[i].eb) return 0;
  }
  return 1;
}
int main() {
  int i, j, k, sig = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d %d %d %d", &p[i].sa, &p[i].ea, &p[i].sb, &p[i].eb);
  sig &= solve();
  for (i = 1; i <= n; i++) swap(p[i].sa, p[i].sb), swap(p[i].ea, p[i].eb);
  sig &= solve();
  if (sig)
    printf("YES\n");
  else
    printf("NO\n");
}
