#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
typedef struct {
  int a;
  double p;
} tpo;
int main() {
  long long i, j, n, a[200], k, s, smax = -1;
  long long sum = 0, x1, y1, x2, y2, minx, miny, maxx, maxy;
  cin >> n;
  cin >> x1 >> y1 >> x2 >> y2;
  minx = x1;
  maxx = x2;
  miny = y1;
  maxy = y2;
  sum = (x2 - x1) * (y2 - y1);
  for (i = 1; i < n; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 < minx) minx = x1;
    if (x2 > maxx) maxx = x2;
    if (y1 < miny) miny = y1;
    if (y2 > maxy) maxy = y2;
    sum += (x1 - x2) * (y1 - y2);
  }
  if (sum == (maxx - minx) * (maxy - miny) && (maxx - minx) == (maxy - miny))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
