#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, a, b, c, d, xl, yl, xr, yr, Sp = 0;
  xr = yr = 0;
  xl = yl = 40000;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c >> d;
    xl = min(a, xl);
    yl = min(b, yl);
    xr = max(c, xr);
    yr = max(d, yr);
    Sp += (c - a) * (d - b);
  }
  if ((Sp == (xr - xl) * (yr - yl)) && ((xr - xl) == (yr - yl)))
    cout << "YES " << endl;
  else
    cout << "NO" << endl;
  return 0;
}
