#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long area = 0;
  cin >> n;
  int mx, my, dx, dy;
  mx = 100000;
  my = 100000;
  dx = -1;
  dy = -1;
  while (n--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < mx) mx = a;
    if (c > dx) dx = c;
    if (b < my) my = b;
    if (d > dy) dy = d;
    area += (c - a) * (d - b);
  }
  if (area == (long long)(dx - mx) * (dx - mx) && (dx - mx) == (dy - my))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
