#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
int N;
struct Node {
  int x1, y1, x2, y2;
  Node(int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0)
      : x1(x1), y1(y1), x2(x2), y2(y2) {}
} n[2005];
bool cmpx(const Node& n1, const Node& n2) { return n1.x1 < n2.x1; }
bool cmpy(const Node& n1, const Node& n2) { return n1.y1 < n2.y1; }
long long cnt = 0;
Node t[2005][2005];
bool f(Node a[], int l, int r) {
  if (l == r) return 1;
  int len = r - l + 1;
  int k = ++cnt;
  for (int i = l; i <= r; i++) {
    t[k][i - l] = a[i];
  }
  sort(t[k], t[k] + len, cmpx);
  int r2 = t[k][0].x2;
  for (int i = l + 1; i <= r; i++) {
    if (t[k][i - l].x1 >= r2) {
      if (f(t[k], 0, i - l - 1) && f(t[k], i - l, len - 1))
        return 1;
      else
        return 0;
    }
    r2 = max(r2, t[k][i - l].x2);
  }
  sort(t[k], t[k] + len, cmpy);
  r2 = t[k][0].y2;
  for (int i = l + 1; i <= r; i++) {
    if (t[k][i - l].y1 >= r2) {
      if (f(t[k], 0, i - l - 1) && f(t[k], i - l, len - 1))
        return 1;
      else
        return 0;
    }
    r2 = max(r2, t[k][i - l].y2);
  }
  return 0;
}
int main() {
  cin >> N;
  int x1, y1, x2, y2;
  for (int i = 1; i <= N; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    n[i] = Node(x1, y1, x2, y2);
  }
  if (f(n, 1, N))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
