#include <bits/stdc++.h>
using namespace std;
vector<int> h1, h2;
int xx1[1005], yy1[1005], xx2[1005], yy2[1005];
int dp[2005][2005];
int dp1[2005][2005], dp2[2005][2005];
set<pair<pair<int, int>, pair<int, int> > > dp3;
bool solve(int x1, int y1, int x2, int y2) {
  if (x1 == x2 && y1 == y2) {
    return 1;
  }
  if (dp3.find(pair<pair<int, int>, pair<int, int> >(
          pair<int, int>(x1, y1), pair<int, int>(x2, y2))) != dp3.end()) {
    return 1;
  }
  for (int i = x1; i <= x2 - 1; i++) {
    if (dp1[i][y2] - dp1[i][y1 - 1] > 0) continue;
    return (solve(x1, y1, i, y2) & solve(i + 1, y1, x2, y2));
  }
  for (int i = y1; i <= y2 - 1; i++) {
    if (dp2[i][x2] - dp2[i][x1 - 1] > 0) continue;
    return (solve(x1, y1, x2, i) & solve(x1, i + 1, x2, y2));
  }
  return 0;
}
int main() {
  int n, a, b, c, d;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    a++, b++;
    xx1[i] = a;
    xx2[i] = c;
    yy1[i] = b;
    yy2[i] = d;
    h1.push_back(a);
    h1.push_back(c);
    h2.push_back(b);
    h2.push_back(d);
  }
  sort(h1.begin(), h1.end());
  sort(h2.begin(), h2.end());
  h1.erase(unique(h1.begin(), h1.end()), h1.end());
  h2.erase(unique(h2.begin(), h2.end()), h2.end());
  for (int i = 1; i <= n; i++) {
    xx1[i] = lower_bound(h1.begin(), h1.end(), xx1[i]) - h1.begin() + 1;
    xx2[i] = lower_bound(h1.begin(), h1.end(), xx2[i]) - h1.begin() + 1;
    yy1[i] = lower_bound(h2.begin(), h2.end(), yy1[i]) - h2.begin() + 1;
    yy2[i] = lower_bound(h2.begin(), h2.end(), yy2[i]) - h2.begin() + 1;
    dp3.insert(pair<pair<int, int>, pair<int, int> >(
        pair<int, int>(xx1[i], yy1[i]), pair<int, int>(xx2[i], yy2[i])));
    for (int j = xx1[i]; j <= xx2[i]; j++) {
      for (int k = yy1[i]; k <= yy2[i]; k++) {
        dp[j][k] = i;
      }
    }
  }
  n = h1.size();
  int m = h2.size();
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= m; j++) {
      dp1[i][j] += dp1[i][j - 1];
      if (dp[i][j] == 0) continue;
      if (dp[i][j] == dp[i + 1][j]) dp1[i][j]++;
    }
  }
  for (int j = 1; j <= m - 1; j++) {
    for (int i = 1; i <= n; i++) {
      dp2[j][i] += dp2[j][i - 1];
      if (dp[i][j] == 0) continue;
      if (dp[i][j] == dp[i][j + 1]) dp2[j][i]++;
    }
  }
  if (solve(1, 1, n, m))
    printf("YES\n");
  else
    printf("NO\n");
}
