#include <bits/stdc++.h>
#pragma comment(linker, "/stack:256000000")
using namespace std;
const int INF = 1000000000;
const long long LINF = 4000000000000000000LL;
const double eps = 1e-9;
void prepare() {}
int n;
int xl[10], yr[10], xr[10], yl[10];
void read() {
  scanf("%d", &n);
  for (int i = (0); i < ((n)); i++) {
    scanf("%d%d", &xl[i], &yl[i]);
    scanf("%d%d", &xr[i], &yr[i]);
  }
}
bool solve() {
  long long sq = 0;
  int minx = INF, maxx = -INF, miny = INF, maxy = -INF;
  for (int i = (0); i < ((n)); i++) {
    sq += (xr[i] - xl[i]) * (yr[i] - yl[i]);
    minx = min(minx, xl[i]);
    miny = min(miny, yl[i]);
    maxx = max(maxx, xr[i]);
    maxy = max(maxy, yr[i]);
  }
  if (maxx - minx == maxy - miny && sq == (maxx - minx) * (maxy - miny))
    printf("YES\n");
  else
    printf("NO\n");
  return false;
}
int main() {
  prepare();
  read();
  while (solve())
    ;
  return 0;
}
