#include <bits/stdc++.h>
int a[51][51], b[51][51], maxx = -10001, maxy = -10001, minx = 1000001,
                          miny = 1000001, n;
long jg, sum;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a[i][1], &a[i][2], &b[i][1], &b[i][2]);
    sum = sum + (b[i][1] - a[i][1]) * (b[i][2] - a[i][2]);
    if (a[i][1] > maxx) maxx = a[i][1];
    if (b[i][1] > maxx) maxx = b[i][1];
    if (a[i][1] < minx) minx = a[i][1];
    if (b[i][1] < minx) minx = b[i][1];
    if (a[i][2] > maxy) maxy = a[i][2];
    if (b[i][2] > maxy) maxy = b[i][2];
    if (a[i][2] < miny) miny = a[i][2];
    if (b[i][2] < miny) miny = b[i][2];
  }
  jg = (maxx - minx) * (maxy - miny);
  if (sum == jg && (maxx - minx) == (maxy - miny))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
