#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long mod = 1000000007;
long long custom_ceil(long long Nr, long long Dr) {
  if (Nr % Dr == 0)
    return Nr / Dr;
  else
    return Nr / Dr + 1;
}
void solve() {
  long long n;
  cin >> n;
  long long x1 = INF, y1 = INF, x2 = -INF, y2 = -INF;
  long long area = 0;
  for (long long i = 0; i < n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    x1 = min(x1, a);
    x2 = max(x2, c);
    y1 = min(y1, b);
    y2 = max(y2, d);
    area += ((c - a) * (d - b));
  }
  if (area == (x2 - x1) * (y2 - y1) && x2 - x1 == y2 - y1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
