#include <bits/stdc++.h>
using namespace std;
int main() {
  int d = 0;
  long long s = 0;
  int x[5], x1[5], y1[5], y[5];
  int minx = 33334, miny = 33334, maxy = 0, maxx = 0;
  cin >> d;
  for (int i = 0; i < d; i++) {
    cin >> x[i] >> y[i] >> x1[i] >> y1[i];
    s += (x1[i] - x[i]) * (y1[i] - y[i]);
  }
  for (int i = 0; i < d; i++) {
    if (minx > x[i]) minx = x[i];
    if (maxx < x1[i]) maxx = x1[i];
    if (miny > y[i]) miny = y[i];
    if (maxy < y1[i]) maxy = y1[i];
  }
  if ((maxx - minx) * (maxy - miny) == s && maxx - minx == maxy - miny)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
