#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1[10], x2[10], y1[10], y2[10];
  int i, j;
  cin >> n;
  int xl = 40000, yl = 40000;
  int xr = 0, yr = 0;
  int sum1 = 0, sum2 = 0;
  for (i = 0; i < n; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    sum1 += (x2[i] - x1[i]) * (y2[i] - y1[i]);
    if (x1[i] <= xl && y1[i] <= yl) {
      xl = x1[i];
      yl = y1[i];
    }
    if (x2[i] >= xr && y2[i] >= yr) {
      xr = x2[i];
      yr = y2[i];
    }
  }
  sum2 = (xr - xl) * (yr - yl);
  int flag = 0;
  if (sum1 == sum2 && xr - xl == yr - yl) {
    for (j = 0; j < n; j++) {
      if (x1[j] < xl || x1[j] > xr || x2[j] < xl || x2[j] > xr || y1[j] < yl ||
          y1[j] > yr || y2[j] < yl || y2[j] > yr)
        flag = 1;
    }
    if (flag == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
