#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 10;
int n, a, b, c, d;
struct node {
  int x1, y1, x2, y2;
  inline bool operator<(const node &b) const {
    if (x1 != b.x1) return x1 < b.x1;
    if (x2 != b.x2) return x2 < b.x2;
    if (y1 != b.y1) return y1 < b.y1;
    return y2 < b.y2;
  }
};
struct Node {
  int x1, y1, x2, y2;
  inline bool operator<(const Node &b) const {
    if (y1 != b.y1) return y1 < b.y1;
    if (y2 != b.y2) return y2 < b.y2;
    if (x1 != b.x1) return x1 < b.x1;
    return x2 < b.x2;
  }
};
set<node> s1;
set<Node> s2;
inline bool split(set<node> a, set<Node> b) {
  if (a.size() == 1) return 1;
  set<node> s1, s2;
  set<Node> S1, S2;
  int Max = (*a.begin()).x2, flag = 0;
  while (a.size()) {
    node v = *a.begin();
    if (v.x1 >= Max) {
      flag = 1;
      break;
    }
    s1.insert(v), S1.insert((Node){v.x1, v.y1, v.x2, v.y2}), a.erase(v);
    Max = max(Max, v.x2);
  }
  if (flag) {
    if (!split(s1, S1)) return 0;
    for (auto v : S1) b.erase(v);
    return split(a, b);
  }
  Max = (*b.begin()).y2, flag = 0;
  while (b.size()) {
    Node v = *b.begin();
    if (v.y1 >= Max) {
      flag = 1;
      break;
    }
    s2.insert((node){v.x1, v.y1, v.x2, v.y2}), S2.insert(v), b.erase(v);
    Max = max(Max, v.y2);
  }
  if (flag) {
    if (!split(s2, S2)) return 0;
    for (auto v : s2) s1.erase(v);
    return split(s1, b);
  }
  return 0;
}
int main() {
  n = read();
  for (register int i = (1); i <= (n); i++)
    a = read(), b = read(), c = read(), d = read(),
    s1.insert((node){a, b, c, d}), s2.insert((Node){a, b, c, d});
  puts(split(s1, s2) ? "YES" : "NO");
}
