#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int MAXN = 10;
int x[MAXN][2], y[MAXN][2];
int main() {
  int n;
  cin >> n;
  long long s = 0;
  int minx = 31401, miny = 31401, maxx = -1, maxy = -1;
  for (int i = 0; i < n; ++i) {
    cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
    minx = min(x[i][0], minx);
    miny = min(y[i][0], miny);
    maxx = max(x[i][1], maxx);
    maxy = max(y[i][1], maxy);
    s += (x[i][1] - x[i][0]) * (y[i][1] - y[i][0]);
  }
  long long s_0 = (maxx - minx) * (maxy - miny);
  if (maxx - minx == maxy - miny && s_0 == s) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
