#include <bits/stdc++.h>
using namespace std;
int n;
int nx, ny;
int a[1010], b[1010], c[1010], d[1010];
vector<int> ac, bd;
int s[2010][2010];
int sx[2010][2010], sy[2010][2010];
bool dame;
void solve(int lx, int rx, int ly, int ry) {
  if (s[rx - 1][ry - 1] - s[lx - 1][ry - 1] - s[rx - 1][ly - 1] +
          s[lx - 1][ly - 1] ==
      1)
    return;
  for (int i = lx + 1; i < rx; i++) {
    if (sx[i][ry - 1] - sx[i - 1][ry - 1] - sx[i][ly - 1] + sx[i - 1][ly - 1] ==
            0 &&
        s[i - 1][ry - 1] - s[lx - 1][ry - 1] - s[i - 1][ly - 1] +
                s[lx - 1][ly - 1] >
            0 &&
        s[rx - 1][ry - 1] - s[i - 1][ry - 1] - s[rx - 1][ly - 1] +
                s[i - 1][ly - 1] >
            0) {
      solve(lx, i, ly, ry);
      solve(i, rx, ly, ry);
      return;
    }
  }
  for (int i = ly + 1; i < ry; i++) {
    if (sy[rx - 1][i] - sy[lx - 1][i] - sy[rx - 1][i - 1] + sy[lx - 1][i - 1] ==
            0 &&
        s[rx - 1][i - 1] - s[lx - 1][i - 1] - s[rx - 1][ly - 1] +
                s[lx - 1][ly - 1] >
            0 &&
        s[rx - 1][ry - 1] - s[rx - 1][i - 1] - s[lx - 1][ry - 1] +
                s[lx - 1][i - 1] >
            0) {
      solve(lx, rx, ly, i);
      solve(lx, rx, i, ry);
      return;
    }
  }
  dame = 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
    ac.push_back(a[i]);
    ac.push_back(c[i]);
    bd.push_back(b[i]);
    bd.push_back(d[i]);
  }
  sort(ac.begin(), ac.end());
  sort(bd.begin(), bd.end());
  ac.erase(unique(ac.begin(), ac.end()), ac.end());
  bd.erase(unique(bd.begin(), bd.end()), bd.end());
  nx = ac.size(), ny = bd.size();
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(ac.begin(), ac.end(), a[i]) - ac.begin() + 1;
    c[i] = lower_bound(ac.begin(), ac.end(), c[i]) - ac.begin() + 1;
    b[i] = lower_bound(bd.begin(), bd.end(), b[i]) - bd.begin() + 1;
    d[i] = lower_bound(bd.begin(), bd.end(), d[i]) - bd.begin() + 1;
  }
  for (int i = 0; i < n; i++) {
    s[a[i]][b[i]]++;
    sx[a[i] + 1][b[i]]++;
    sx[c[i]][b[i]]--;
    sx[a[i] + 1][d[i]]--;
    sx[c[i]][d[i]]++;
    sy[a[i]][b[i] + 1]++;
    sy[c[i]][b[i] + 1]--;
    sy[a[i]][d[i]]--;
    sy[c[i]][d[i]]++;
  }
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j <= ny; j++)
      s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j < ny; j++)
      sx[i][j + 1] += sx[i][j], sy[i][j + 1] += sy[i][j];
  for (int i = 1; i < nx; i++)
    for (int j = 1; j <= ny; j++)
      sx[i + 1][j] += sx[i][j], sy[i + 1][j] += sy[i][j];
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j <= ny; j++)
      sx[i][j] += sx[i - 1][j] + sx[i][j - 1] - sx[i - 1][j - 1];
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j <= ny; j++)
      sy[i][j] += sy[i - 1][j] + sy[i][j - 1] - sy[i - 1][j - 1];
  solve(1, nx, 1, ny);
  if (dame)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
