#include <bits/stdc++.h>
using namespace std;
int Max(int a, int b) { return a > b ? a : b; }
int Min(int a, int b) { return a < b ? a : b; }
int main() {
  int x1, x2, y1, y2, mx, my, tem, sum, n;
  int mix;
  int miy;
  scanf("%d", &n);
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  tem = (y2 - y1) * (x2 - x1);
  sum = tem;
  mx = x2;
  mix = x1;
  miy = y1;
  my = y2;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    mx = Max(mx, x2);
    my = Max(my, y2);
    mix = Min(mix, x1);
    miy = Min(miy, y1);
    tem = (y2 - y1) * (x2 - x1);
    sum += tem;
  }
  if ((mx - mix == my - miy) && ((mx - mix) * (my - miy) == sum)) {
    puts("YES");
  } else
    puts("NO");
  return 0;
}
