#include <bits/stdc++.h>
using namespace std;
struct P {
  int x1, y1, x2, y2;
};
vector<P> v[1111];
int i, n, m, k, a, d, b, c;
int e;
int o[1];
int l[11];
int j[1];
int dx[10] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[10] = {1, 0, -1, 0, 1, -1, 1, -1},
    dz[10] = {0, 0, 0, 0, 1, -1};
int px[10] = {-1, 1, 1, -1, 1, 1, -1, -1},
    py[10] = {1, 1, -1, -1, 1, -1, 1, -1};
long long mod = 1000000007, mod2 = 1000000009, mod3 = 2017;
long long x, z, y;
double pi = 3.14159265;
P u[1];
stack<int> s;
queue<int> q;
char r[2];
map<int, int> p;
bool asd(P a, P b) {
  if (a.y1 != b.y1) return a.y1 < b.y1;
  return a.y2 > b.y2;
}
bool as(P a, P b) {
  if (a.x1 != b.x1) return a.x1 < b.x1;
  return a.x2 > b.x2;
}
int f(int n) {
  if (v[n].size() <= 2) return 1;
  sort(v[n].begin(), v[n].end(), as);
  int x = 0;
  for (int h = 0; h + 1 < v[n].size(); h++)
    if (max(v[n][h].x2, x) <= v[n][h + 1].x1) {
      int c = 0, d = 0;
      v[n + 1].erase(v[n + 1].begin(), v[n + 1].end());
      for (int i = 0; i <= h; i++) v[n + 1].push_back(v[n][i]);
      c = f(n + 1);
      v[n + 1].erase(v[n + 1].begin(), v[n + 1].end());
      for (int i = h + 1; i < v[n].size(); i++) v[n + 1].push_back(v[n][i]);
      d = f(n + 1);
      return c * d;
    } else
      x = max(x, v[n][h].x2);
  x = 0;
  sort(v[n].begin(), v[n].end(), asd);
  for (int h = 0; h + 1 < v[n].size(); h++)
    if (max(v[n][h].y2, x) <= v[n][h + 1].y1) {
      int c = 0, d = 0;
      v[n + 1].erase(v[n + 1].begin(), v[n + 1].end());
      for (int i = 0; i <= h; i++) v[n + 1].push_back(v[n][i]);
      c = f(n + 1);
      v[n + 1].erase(v[n + 1].begin(), v[n + 1].end());
      for (int i = h + 1; i < v[n].size(); i++) v[n + 1].push_back(v[n][i]);
      d = f(n + 1);
      return c * d;
    } else
      x = max(x, v[n][h].y2);
  return 0;
}
int main() {
  scanf("%d", &a);
  for (int t = 1; t <= a; t++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    v[0].push_back({x1, y1, x2, y2});
  }
  if (f(0))
    puts("YES");
  else
    puts("NO");
}
