#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 100;
const int MAXN = 100 * 1000;
long long x1[MAXN], x2[MAXN], kufjlv[MAXN], y2[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long s = 0;
  long long ma_x = -INF, mi_x = INF, ma_y = -INF, mi_y = INF;
  for (int i = 0; i < n; i++) {
    cin >> x1[i] >> kufjlv[i] >> x2[i] >> y2[i];
    ma_x = max(ma_x, x1[i]);
    ma_x = max(ma_x, x2[i]);
    mi_x = min(mi_x, x1[i]);
    mi_x = min(mi_x, x2[i]);
    ma_y = max(ma_y, kufjlv[i]);
    ma_y = max(ma_y, y2[i]);
    mi_y = min(mi_y, kufjlv[i]);
    mi_y = min(mi_y, y2[i]);
    s += abs((x1[i] - x2[i]) * (y2[i] - kufjlv[i]));
  }
  if (s == (ma_x - mi_x) * (ma_y - mi_y) && (ma_x - mi_x) == (ma_y - mi_y)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
