#include <bits/stdc++.h>
using namespace std;
int n;
int x[10][2];
int y[10][2];
int xl = 31400, yl = 31400, xr = 0, yr = 0;
bool Check(double px, double py) {
  if (px < xl || px > xr || py < yl || py > yr) return 1;
  for (int i = 0; i < n; i++)
    if (px >= x[i][0] && px <= x[i][1] && py >= y[i][0] && py <= y[i][1])
      return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x[i][0], &y[i][0], &x[i][1], &y[i][1]);
    xl = min(x[i][0], xl);
    xr = max(x[i][1], xr);
    yl = min(y[i][0], yl);
    yr = max(y[i][1], yr);
  }
  bool ans = 1;
  for (int i = 0; i < n; i++) {
    for (int j = x[i][0]; j < x[i][1]; j++) {
      ans &= Check(j + 0.5, y[i][0] - 0.5);
      ans &= Check(j + 0.5, y[i][1] + 0.5);
    }
    for (int j = y[i][0]; j < y[i][1]; j++) {
      ans &= Check(x[i][0] - 0.5, j + 0.5);
      ans &= Check(x[i][1] + 0.5, j + 0.5);
    }
  }
  if (ans && (xr - xl) == yr - yl)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
