#include <bits/stdc++.h>
namespace FastIO {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
inline void wrap() {
  *oS++ = '\n';
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  I sign = 1;
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') sign = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= sign;
}
inline int gi() {
  int x, sign = 1;
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') sign = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  return x * sign;
}
inline long long gl() {
  long long x, sign = 1;
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') sign = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  return x * sign;
}
template <class I>
inline void print(I &x) {
  if (!x) putc('0');
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
template <class I>
inline void println(I &x) {
  if (!x) putc('0');
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
  wrap();
}
}  // namespace FastIO
using namespace std;
int n;
struct Rectangle {
  int l, r, d, u;
} rec[1000 + 5];
bool solve(vector<Rectangle> v) {
  if (v.size() <= 1) return 1;
  int maxr = 0, maxu = 0;
  bool flag = 0;
  vector<Rectangle> pre, suf;
  sort(v.begin(), v.end(),
       [](const Rectangle &a, const Rectangle &b) { return a.l < b.l; });
  for (int i = v.size() - 1; ~i; --i) suf.push_back(v[i]);
  for (int i = 0; i < v.size() - 1; ++i) {
    pre.push_back(v[i]), suf.pop_back();
    maxr = max(maxr, v[i].r);
    if (maxr <= v[i + 1].l && solve(pre) && solve(suf)) {
      flag = 1;
      break;
    }
  }
  if (flag) return true;
  sort(v.begin(), v.end(),
       [](const Rectangle &a, const Rectangle &b) { return a.d < b.d; });
  pre.clear();
  suf.clear();
  for (int i = v.size() - 1; ~i; --i) suf.push_back(v[i]);
  for (int i = 0; i < v.size() - 1; ++i) {
    pre.push_back(v[i]), suf.pop_back();
    maxu = max(maxu, v[i].u);
    if (maxu <= v[i + 1].d && solve(pre) && solve(suf)) {
      flag = 1;
      break;
    }
  }
  if (flag) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  vector<Rectangle> v;
  for (int i = 1, a, b, c, d; i <= n; ++i) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    rec[i] = {a, c, b, d};
    v.push_back(rec[i]);
  }
  if (solve(v))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
