#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long int read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  long long int x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
const long long int N = 4e5;
long long int A[N + 5], B[N + 5], C[N + 5], D[N + 5], n;
long long int U[N + 5][2];
struct node {
  long long int isquery, pos, l, r;
  node(long long int _isquery, long long int _pos, long long int _l,
       long long int _r)
      : isquery(_isquery), pos(_pos), l(_l), r(_r) {}
  friend bool operator<(node a, node b) {
    if (a.pos != b.pos)
      return a.pos < b.pos;
    else
      return a.isquery;
  }
};
void insert(long long int which, long long int pos) {
  while (pos <= N) {
    U[pos][which] += 1;
    pos += (pos & (-pos));
  }
}
long long int getsum(long long int which, long long int pos) {
  long long int re = 0;
  while (pos > 0) {
    re += U[pos][which];
    pos -= (pos & (-pos));
  }
  return re;
}
bool solve(long long int A[], long long int B[], long long int C[],
           long long int D[], long long int n) {
  memset(U, 0, sizeof(U));
  vector<node> V;
  for (long long int i = 0; i < n; i++) {
    V.push_back(node(1, A[i], C[i], D[i]));
    V.push_back(node(0, B[i], C[i], D[i]));
  }
  stable_sort(V.begin(), V.end());
  long long int cnt = 0;
  for (long long int i = 0; i < V.size(); i++) {
    if (V[i].isquery) {
      long long int p = getsum(1, V[i].l - 1),
                    q = getsum(0, N) - getsum(0, V[i].r);
      if (p + q != cnt) return false;
    } else {
      insert(0, V[i].l);
      insert(1, V[i].r);
      cnt++;
    }
  }
  return true;
}
int main() {
  map<long long int, long long int> M;
  n = read();
  vector<long long int> V;
  for (long long int i = 0; i < n; i++) {
    A[i] = read();
    B[i] = read();
    C[i] = read();
    D[i] = read();
    V.push_back(A[i]);
    V.push_back(B[i]);
    V.push_back(C[i]);
    V.push_back(D[i]);
  }
  random_shuffle(V.begin(), V.end());
  stable_sort(V.begin(), V.end());
  for (long long int i = 0; i < V.size(); i++) {
    if (i && V[i] == V[i - 1])
      M[V[i]] = M[V[i - 1]];
    else
      M[V[i]] = i + 1;
  }
  for (long long int i = 0; i < n; i++) {
    A[i] = M[A[i]];
    B[i] = M[B[i]];
    C[i] = M[C[i]];
    D[i] = M[D[i]];
  }
  long long int p = solve(A, B, C, D, n);
  long long int q = solve(C, D, A, B, n);
  (p && q) ? puts("YES") : puts("NO");
}
