#include <bits/stdc++.h>
using namespace std;
int a[10][5];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i][1];
    cin >> a[i][2];
    cin >> a[i][3];
    cin >> a[i][4];
  }
  int minx = 31401, maxx = -9, miny = 31401, maxy = -9;
  for (int i = 1; i <= n; i++) {
    if (a[i][1] < minx) minx = a[i][1];
    if (a[i][2] < miny) miny = a[i][2];
    if (a[i][3] > maxx) maxx = a[i][3];
    if (a[i][4] > maxy) maxy = a[i][4];
  }
  int uz = 0, dz = 0, rz = 0, lz = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i][1] == minx) lz += a[i][4] - a[i][2];
    if (a[i][3] == maxx) rz += a[i][4] - a[i][2];
    if (a[i][2] == miny) dz += a[i][3] - a[i][1];
    if (a[i][4] == maxy) uz += a[i][3] - a[i][1];
  }
  int t = 1;
  if (uz != (maxx - minx) or dz != (maxx - minx) or rz != (maxy - miny) or
      lz != (maxy - miny))
    t = 0;
  int s = 0;
  if (t == 1) {
    for (int i = 1; i <= n; i++) s += (a[i][4] - a[i][2]) * (a[i][3] - a[i][1]);
    if (s != (maxx - minx) * (maxy - miny)) t = 0;
  }
  if (maxy - miny != maxx - minx) t = 0;
  if (t == 0)
    cout << "NO";
  else
    cout << "YES";
}
