#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
struct rect {
  int x1;
  int _dsfkjdsfksdj;
  int x2;
  int y2;
  void read() { scanf("%d%d%d%d", &x1, &_dsfkjdsfksdj, &x2, &y2); }
};
const int MAXN = 5;
int n;
rect a[MAXN];
int X1, Y1, X2, Y2;
long long S1, S2;
int main() {
  S1 = S2 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    a[i].read();
    if (a[i].x1 > a[i].x2) swap(a[i].x1, a[i].x2);
    if (a[i]._dsfkjdsfksdj > a[i].y2) swap(a[i]._dsfkjdsfksdj, a[i].y2);
    S1 += (long long)(a[i].x2 - a[i].x1) *
          (long long)(a[i].y2 - a[i]._dsfkjdsfksdj);
  }
  X1 = a[0].x1;
  Y1 = a[0]._dsfkjdsfksdj;
  X2 = a[0].x2;
  Y2 = a[0].y2;
  for (int i = 1; i < n; ++i) {
    X1 = min(X1, a[i].x1);
    X2 = max(X2, a[i].x2);
    Y1 = min(Y1, a[i]._dsfkjdsfksdj);
    Y2 = max(Y2, a[i].y2);
  }
  S2 += (long long)(X2 - X1) * (long long)(Y2 - Y1);
  if (S1 == S2 && (X2 - X1) == (Y2 - Y1))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
