#include <bits/stdc++.h>
using namespace std;
struct R {
  int sx, sy, tx, ty;
  R(int sx, int sy, int tx, int ty) : sx(sx), sy(sy), tx(tx), ty(ty) {}
};
int n;
vector<int> xs, ys;
vector<R> rs;
map<int, int> compress(vector<int>& v) {
  map<int, int> vmap;
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < v.size(); i++) {
    vmap[v[i]] = i;
  }
  return vmap;
}
int main() {
  cin >> n;
  int xmin = (31500), ymin = (31500);
  int xmax = 0, ymax = 0;
  for (int i = 0; i < n; i++) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rs.push_back(R(sx, sy, tx, ty));
    xs.push_back(sx);
    xs.push_back(tx);
    ys.push_back(sy);
    ys.push_back(ty);
    xmax = max(xmax, tx);
    xmin = min(xmin, sx);
    ymax = max(ymax, ty);
    ymin = min(ymin, sy);
  }
  xs.push_back(xmax);
  xs.push_back(xmin);
  ys.push_back(ymax);
  ys.push_back(ymin);
  map<int, int> xmap = compress(xs);
  map<int, int> ymap = compress(ys);
  int xsize = xmap.size() - 1;
  int ysize = ymap.size() - 1;
  bool f[ysize][xsize];
  memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i++) {
    for (int j = ymap[rs[i].sy]; j < ymap[rs[i].ty]; j++) {
      for (int k = xmap[rs[i].sx]; k < xmap[rs[i].tx]; k++) {
        f[j][k] = true;
      }
    }
  }
  if (ymax - ymin != xmax - xmin) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < ysize; i++) {
    for (int j = 0; j < xsize; j++) {
      if (!f[i][j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
