#include <bits/stdc++.h>
const int INF = (int)1e9;
const int NINF = -(int)1e9;
const int mod = (int)1e9 + 7;
const double EPS = 1e-10;
const int M = 100005;
using namespace std;
template <class T>
T gcd(T a, T b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
template <class T>
T lcd(T a, T b) {
  return abs(a * b) / gcd(a, b);
}
void init() {}
int main() {
  int n;
  cin >> n;
  int arr[n][4], area = 0;
  int maxr = NINF, maxc = NINF, minr = INF, minc = INF;
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2] >> arr[i][3];
    area += ((arr[i][3] - arr[i][1]) * (arr[i][2] - arr[i][0]));
    maxr = (maxr > arr[i][2] ? maxr : arr[i][2]);
    maxc = (maxc > arr[i][3] ? maxc : arr[i][3]);
    minc = (minc < arr[i][1] ? minc : arr[i][1]);
    minr = (minr < arr[i][0] ? minr : arr[i][0]);
  }
  if (area == ((maxc - minc) * (maxr - minr)) && (maxr - minr) == (maxc - minc))
    cout << "YES" << endl;
  else
    cout << "NO\n";
  return 0;
}
