#include <bits/stdc++.h>
using namespace std;
int n;
double first[55], second[55], X[55], Y[55];
double minx = 999999, miny = 999999, maxx = -1, maxy = -1;
vector<double> vx, vy;
double dx[] = {0.1, 0, -0.1, 0}, dy[] = {0, 0.1, 0, -0.1};
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> first[i] >> second[i] >> X[i] >> Y[i];
    minx = min(first[i], minx);
    miny = min(second[i], miny);
    maxx = max(X[i], maxx);
    maxy = max(Y[i], maxy);
    for (int d = 0; d < 4; ++d) {
      vx.push_back(first[i] + dx[d]);
      vx.push_back(X[i] + dx[d]);
      vy.push_back(second[i] + dy[d]);
      vy.push_back(Y[i] + dy[d]);
    }
  }
  if (maxx - minx != maxy - miny) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < vx.size(); ++i)
    if (vx[i] >= minx && vx[i] <= maxx)
      for (int j = 0; j < vy.size(); ++j)
        if (vy[j] >= miny && vy[j] <= maxy) {
          int ok = 0;
          for (int k = 1; k <= n; ++k)
            if (vx[i] >= first[k] && vx[i] <= X[k] && vy[j] >= second[k] &&
                vy[j] <= Y[k])
              ok = 1;
          if (!ok) {
            cout << "NO";
            return 0;
          }
        }
  cout << "YES";
  return 0;
}
