#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <typename T>
void ckmax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
void ckmin(T &a, T b) {
  if (a > b) a = b;
}
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 6;
long long xl, xr, yl, yr, ans;
int n;
int main() {
  cin >> n;
  xl = yl = 1e9;
  xr = yr = -1e9;
  while (n--) {
    long long x, y, xx, yy;
    cin >> x >> y >> xx >> yy;
    ans += (xx - x) * (yy - y);
    ckmin(xl, x), ckmax(xr, xx);
    ckmin(yl, y), ckmax(yr, yy);
  }
  puts(ans == (xr - xl) * (yr - yl) ? xr - xl == yr - yl ? "YES" : "NO" : "NO");
  return 0;
}
