#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 200005;
int n;
int xcnt = 0, ycnt = 0;
int X[N << 1], Y[N << 1];
struct node {
  int a, b, c, d;
} p[N];
vector<int> xx[N << 1], yy[N << 1], now;
int check(int x1, int y1, int x2, int y2, vector<int> now) {
  if ((int)now.size() < 2) return 1;
  for (int x = x1 + 1; x < x2; ++x) {
    if (xx[x].empty()) continue;
    int flag = 1;
    vector<int> tmp1, tmp2;
    for (int i = 0; i < (int)now.size(); ++i) {
      int idx = now[i];
      if (p[idx].a < x && p[idx].c > x) {
        flag = 0;
        break;
      }
      if (p[idx].c <= x)
        tmp1.push_back(idx);
      else
        tmp2.push_back(idx);
    }
    if (!flag || tmp1.empty() || tmp2.empty()) continue;
    return check(x1, y1, x, y2, tmp1) && check(x, y1, x2, y2, tmp2);
  }
  for (int y = y1 + 1; y < y2; ++y) {
    if (yy[y].empty()) continue;
    int flag = 1;
    vector<int> tmp1, tmp2;
    for (int i = 0; i < (int)now.size(); ++i) {
      int idx = now[i];
      if (p[idx].b < y && p[idx].d > y) {
        flag = 0;
        break;
      }
      if (p[idx].d <= y)
        tmp1.push_back(idx);
      else
        tmp2.push_back(idx);
    }
    if (!flag || tmp1.empty() || tmp2.empty()) continue;
    return check(x1, y1, x2, y, tmp1) && check(x1, y, x2, y2, tmp2);
  }
  return 0;
}
void init() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(p[i].a);
    read(p[i].b);
    read(p[i].c);
    read(p[i].d);
    X[++xcnt] = p[i].a;
    X[++xcnt] = p[i].c;
    Y[++ycnt] = p[i].b;
    Y[++ycnt] = p[i].d;
  }
  sort(X + 1, X + xcnt + 1);
  sort(Y + 1, Y + ycnt + 1);
  xcnt = unique(X + 1, X + xcnt + 1) - X - 1;
  ycnt = unique(Y + 1, Y + ycnt + 1) - Y - 1;
  for (int i = 1; i <= n; ++i) {
    p[i].a = lower_bound(X + 1, X + xcnt + 1, p[i].a) - X;
    p[i].c = lower_bound(X + 1, X + xcnt + 1, p[i].c) - X;
    p[i].b = lower_bound(Y + 1, Y + ycnt + 1, p[i].b) - Y;
    p[i].d = lower_bound(Y + 1, Y + ycnt + 1, p[i].d) - Y;
    xx[p[i].a].push_back(i);
    yy[p[i].b].push_back(i);
    xx[p[i].c].push_back(i);
    yy[p[i].d].push_back(i);
  }
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    now.push_back(i);
  }
  if (check(1, 1, xcnt, ycnt, now)) {
    printf("YES\n");
  } else
    printf("NO\n");
}
int main() {
  init();
  solve();
  return 0;
}
