#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = ({
    int a;
    scanf("%d", &a);
    a;
  }),
      xm = 1 << 29, ym = 1 << 29, xmm = 0, ymm = 0, tmp = 0;
  for (__typeof((n)-1) i = (0); i <= ((n)-1); ++i) {
    int x1 = ({
      int a;
      scanf("%d", &a);
      a;
    }),
        y1 = ({
          int a;
          scanf("%d", &a);
          a;
        }),
        x2 = ({
          int a;
          scanf("%d", &a);
          a;
        }),
        y2 = ({
          int a;
          scanf("%d", &a);
          a;
        });
    xm = (xm) < (x1) ? (xm) : (x1);
    xm = (xm) < (x2) ? (xm) : (x2);
    ym = (ym) < (y1) ? (ym) : (y1);
    ym = (ym) < (y2) ? (ym) : (y2);
    xmm = (xmm) > (x1) ? (xmm) : (x1);
    xmm = (xmm) > (x2) ? (xmm) : (x2);
    ymm = (ymm) > (y1) ? (ymm) : (y1);
    ymm = (ymm) > (y2) ? (ymm) : (y2);
    tmp = tmp + ((x2 - x1) * (y2 - y1));
  }
  if ((xmm - xm) != (ymm - ym)) {
    cout << "NO" << endl;
    return 0;
  }
  int area = (xmm - xm) * (ymm - ym);
  if (area == tmp)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
