#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  int x, y, a, b, ldx = 10000000, ldy = 10000000, lux, luy, rdx, rdy, rux = 0,
                  ruy = 0;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> a >> b;
    ldx = min(ldx, min(x, a));
    ldy = min(ldy, min(y, b));
    rux = max(rux, max(x, a));
    ruy = max(ruy, max(y, b));
    sum += (a - x) * (b - y);
  }
  if ((rux - ldx) * (ruy - ldy) == sum && rux - ldx == ruy - ldy)
    puts("YES");
  else
    puts("NO");
  return 0;
}
