#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long s = 0;
  long long minx, miny, maxx, maxy;
  minx = miny = 1e15;
  maxx = maxy = -1e15;
  for (int it = 0; it < int(n); ++it) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    maxx = max(maxx, max(x1, x2));
    maxy = max(maxy, max(y1, y2));
    minx = min(minx, min(x1, x2));
    miny = min(miny, min(y1, y2));
    s += (y2 - y1) * (x2 - x1);
  }
  if ((maxx - minx) == (maxy - miny) && s == (maxx - minx) * (maxy - miny))
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
