#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
} r[7];
int n, X[11], Y[11], Xn, Yn, c[11][11], mx2, my2, Mx2, My2;
int main() {
  scanf("%d", &n);
  mx2 = my2 = 999999;
  Mx2 = My2 = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &r[i].x1, &r[i].y1, &r[i].x2, &r[i].y2);
    X[++Xn] = r[i].x1;
    X[++Xn] = r[i].x2;
    Y[++Yn] = r[i].y1;
    Y[++Yn] = r[i].y2;
    if (mx2 > r[i].x1) mx2 = r[i].x1;
    if (my2 > r[i].y1) my2 = r[i].y1;
    if (Mx2 < r[i].x2) Mx2 = r[i].x2;
    if (My2 < r[i].y2) My2 = r[i].y2;
  }
  sort(X + 1, X + Xn + 1);
  sort(Y + 1, Y + Yn + 1);
  int one = 0, mx, Mx, my, My;
  mx = my = 999;
  Mx = My = -1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= Xn; j++)
      if (r[i].x1 == X[j]) {
        r[i].x1 = j;
        break;
      }
    for (int j = 1; j <= Xn; j++)
      if (r[i].x2 == X[j]) {
        r[i].x2 = j;
        break;
      }
    for (int j = 1; j <= Yn; j++)
      if (r[i].y1 == Y[j]) {
        r[i].y1 = j;
        break;
      }
    for (int j = 1; j <= Yn; j++)
      if (r[i].y2 == Y[j]) {
        r[i].y2 = j;
        break;
      }
    for (int a = r[i].x1; a < r[i].x2; a++)
      for (int b = r[i].y1; b < r[i].y2; b++) {
        c[a][b] = 1, ++one;
        if (mx > a) mx = a;
        if (my > b) my = b;
        if (Mx < a) Mx = a;
        if (My < b) My = b;
      }
  }
  if ((Mx - mx + 1) * (My - my + 1) == one && (Mx2 - mx2) == (My2 - my2))
    puts("YES");
  else
    puts("NO");
  return 0;
}
