#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> sx, sy;
  vector<pair<pair<int, int>, pair<int, int> > > rect(n);
  for (int i = 0; i < n; ++i) {
    cin >> rect[i].first.first >> rect[i].first.second;
    cin >> rect[i].second.first >> rect[i].second.second;
    sx.insert(rect[i].first.first);
    sy.insert(rect[i].first.second);
    sx.insert(rect[i].second.first);
    sy.insert(rect[i].second.second);
  }
  vector<int> vx(sx.begin(), sx.end()), vy(sy.begin(), sy.end());
  map<int, int> mx, my;
  for (int i = 0; i < int(vx.size()); ++i) {
    mx[vx[i]] = i;
  }
  for (int i = 0; i < int(vy.size()); ++i) {
    my[vy[i]] = i;
  }
  vector<vector<bool> > b(vy.size(), vector<bool>(vx.size(), false));
  for (int r = 0; r < n; ++r) {
    for (int i = my[rect[r].first.second]; i < my[rect[r].second.second]; ++i) {
      for (int j = mx[rect[r].first.first]; j < mx[rect[r].second.first]; ++j) {
        b[i][j] = true;
      }
    }
  }
  bool ok = (vx.back() - vx[0] == vy.back() - vy[0]);
  for (int i = 0; i < int(b.size()); ++i) {
    for (int j = 0; j < int(b[i].size()); ++j) {
      if (b[i][j] && i == int(b.size()) - 1) ok = false;
      if (b[i][j] && j == int(b[i].size()) - 1) ok = false;
      if (!b[i][j] && i < int(b.size()) - 1 && j < int(b[i].size()) - 1)
        ok = false;
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
