#include <bits/stdc++.h>
using namespace std;
bool check(int a) {
  if (ceil(sqrt(a)) * ceil(sqrt(a)) == a) return 1;
  return 0;
}
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  int maxx = 0, maxy = 0, miny = 35000, minx = 35000;
  for (int i = 0; i < n; i++) {
    int a, b, x, y;
    cin >> a >> b >> x >> y;
    minx = min(minx, a);
    maxx = max(maxx, x);
    miny = min(miny, b);
    maxy = max(maxy, y);
    sum += (x - a) * (y - b);
  }
  if (((maxx - minx) == 1 || (maxy - miny) == 1) && sum != 1) {
    cout << "NO";
    return 0;
  }
  if (sum == (maxx - minx) * (maxy - miny) && check(sum) == true)
    cout << "YES";
  else
    cout << "NO";
}
