#include <bits/stdc++.h>
using namespace std;
vector<int> x1;
vector<int> yy;
vector<int> x2;
vector<int> y2;
int main() {
  int n;
  cin >> n;
  int size = 0;
  int mx = 40000 * 2;
  int my = 40000 * 2;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    x1.push_back(a);
    yy.push_back(b);
    x2.push_back(c);
    y2.push_back(d);
    mx = min(mx, a);
    my = min(my, b);
    size += (c - a) * (d - b);
  }
  int r = (int)sqrt(size);
  if (r * r != size) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (x1[i] > mx + r) {
      cout << "NO";
      return 0;
    }
    if (x2[i] > mx + r) {
      cout << "NO";
      return 0;
    }
    if (yy[i] > my + r) {
      cout << "NO";
      return 0;
    }
    if (y2[i] > my + r) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
