#include <bits/stdc++.h>
const int maxi = 2000000000;
const int maxq = 1000000000;
const double eps = 1e-10;
const double pi = 3.1415926535897932;
const double inf = 1e+18;
const int mo = 1000000007;
using namespace std;
int n, xmax = -maxi, xmin = maxi, ymax = -maxi, ymin = maxi, x[111111],
       y[111111], xx[111111], yy[111111];
long long s;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> xx[i] >> yy[i];
  for (int i = 1; i <= n; i++) {
    xmax = max(xmax, xx[i]);
    ymax = max(ymax, yy[i]);
    xmin = min(xmin, x[i]);
    ymin = min(ymin, y[i]);
    s = s + 1ll * (xx[i] - x[i]) * (yy[i] - y[i]);
  }
  if (1ll * (xmax - xmin) * (ymax - ymin) == s && xmax - xmin == ymax - ymin) {
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}
