#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int MAXN = 5;
int xA[MAXN], yA[MAXN], xB[MAXN], yB[MAXN];
int main() {
  int n;
  cin >> n;
  int minX = INF, maxX = 0, minY = INF, maxY = 0;
  long long totalSq = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &xA[i], &yA[i], &xB[i], &yB[i]);
    minX = min(minX, xA[i]);
    maxX = max(maxX, xB[i]);
    minY = min(minY, yA[i]);
    maxY = max(maxY, yB[i]);
    totalSq += (xB[i] - xA[i]) * (yB[i] - yA[i]);
  }
  if (maxX - minX == maxY - minY && (maxX - minX) * (maxY - minY) == totalSq) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}
