#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n;
  cin >> n;
  int x1, y1, x2, y2;
  int maxx = 0, maxy = 0;
  int minx = 100000000, miny = 100000000;
  vector<int> xy1;
  vector<int> xy2;
  vector<int> length;
  vector<int> weight;
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    maxx = max(maxx, x2);
    maxy = max(maxy, y2);
    minx = min(minx, x1);
    miny = min(miny, y1);
    length.push_back(abs(x1 - x2));
    weight.push_back(abs(y1 - y2));
  }
  for (int i = 0; i < length.size(); i++) {
    s = s + (length[i] * weight[i]);
  }
  if (s == abs((maxx - minx) * (maxy - miny)) &&
      abs(maxx - minx) == abs(maxy - miny)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
