#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > Xs;
  vector<pair<int, int> > Ys;
  int n, xmi = 0, xma = 0, ymi = 0, yma = 0;
  cin >> n;
  int Sq2 = 0;
  for (int i = 0; i < n; i++) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Xs.push_back(make_pair(x1, x2));
    Ys.push_back(make_pair(y1, y2));
    if (x1 < Xs[xmi].first) xmi = i;
    if (x2 > Xs[xma].second) xma = i;
    if (y1 < Ys[ymi].first) ymi = i;
    if (y2 > Ys[yma].second) yma = i;
    Sq2 += (x2 - x1) * (y2 - y1);
  }
  bool imi = false, ima = false;
  for (int i = 0; i < n; i++) {
    if (Xs[i].first == Xs[xmi].first && Ys[i].first == Ys[ymi].first)
      imi = true;
    if (Xs[i].second == Xs[xma].second && Ys[i].second == Ys[yma].second)
      ima = true;
  }
  if (!imi || !ima ||
      Xs[xma].second - Xs[xmi].first != Ys[yma].second - Ys[ymi].first) {
    cout << "NO" << endl;
    return 0;
  }
  int Sq1 = (Xs[xma].second - Xs[xmi].first) * (Ys[yma].second - Ys[ymi].first);
  if (Sq2 != Sq1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
