#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long s, x_m, y_m, x_b, y_b;
  long long a, b, c, d;
  scanf("%d", &n);
  s = 0;
  x_m = y_m = 40000;
  y_b = x_b = -1;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    x_m = ((x_m) < (a) ? (x_m) : (a));
    y_m = ((y_m) < (b) ? (y_m) : (b));
    x_b = ((c) > (x_b) ? (c) : (x_b));
    y_b = ((y_b) > (d) ? (y_b) : (d));
    s += (c - a) * (d - b);
  }
  long long temp = (y_b - y_m) * (x_b - x_m);
  if (temp == s && (y_b - y_m) == (x_b - x_m))
    puts("YES");
  else
    puts("NO");
  return 0;
}
