#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 105;
const int Mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1);
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
inline int bit(int x) { return 1 << x; }
inline double dabs(double x) { return x > 0 ? x : (-x); }
inline int iabs(int x) { return x > 0 ? x : (-x); }
inline int lowbit(int x) { return x & (-x); }
template <class T>
inline void checkmin(T &a, T b) {
  if (a == -1 || b < a) a = b;
}
int main() {
  int i, n, x1, x2, y1, y2, mx = 99999, Mx = -1, my = 99999, My = -1, R = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    R += (x2 - x1) * (y2 - y1);
    if (Mx < x2) Mx = x2;
    if (My < y2) My = y2;
    if (mx > x1) mx = x1;
    if (my > y1) my = y1;
  }
  if ((Mx - mx) * (My - my) == R && Mx - mx == My - my)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
