#include <bits/stdc++.h>
using namespace std;
class point {
 public:
  int x, y;
  point(int _x, int _y) {
    x = _x;
    y = _y;
  }
  string str() {
    stringstream ss;
    ss << "(" << x << ", " << y << ")";
    return ss.str();
  }
};
int main() {
  int n;
  cin >> n;
  point min = point(31400, 31400), max = point(0, 0);
  int used_area = 0;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    point p1 = point(x1, y1), p2 = point(x2, y2);
    if (x1 < min.x) min.x = x1;
    if (y1 < min.y) min.y = y1;
    if (x2 > max.x) max.x = x2;
    if (y2 > max.y) max.y = y2;
    used_area += (x2 - x1) * (y2 - y1);
  }
  int total_area = (max.x - min.x) * (max.y - min.y);
  if (used_area == total_area && (max.x - min.x) == (max.y - min.y))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
