#include <bits/stdc++.h>
using namespace std;
void Draganov47() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
struct a4 {
  long long x1, y1, x2, y2;
};
vector<a4> a;
vector<int> status;
int n;
bool check(int sz) {
  int dx = 0, dy = 0;
  long long xl = 1e9, yl = 1e9, xr = -1, yr = -1;
  long long s = 0;
  for (int i = 0; i < sz; i++) {
    int j = status[i] - 1;
    a4 b = a[j];
    xl = min(b.x1, xl);
    xr = max(b.x2, xr);
    yl = min(b.y1, yl);
    yr = max(b.y2, yr);
    s += (b.x2 - b.x1) * (b.y2 - b.y1);
  }
  dx = xr - xl;
  dy = yr - yl;
  return dy == dx && (long long)(dx * dx) == s;
}
void f(int i, int sz) {
  if (i == n && sz && check(sz)) {
    cout << "YES";
    exit(0);
  }
  if (i == n) return;
  status[sz] = i + 1;
  f(i + 1, sz + 1);
}
int main() {
  Draganov47();
  cin >> n;
  a.resize(n);
  status.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
  f(0, 0);
  cout << "NO";
  return 0;
}
