#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long sum = 0;
  int mx = 0, my = 0;
  int ix = 1e9, iy = 1e9;
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    sum += abs(y1 - y2) * abs(x1 - x2);
    mx = max({mx, x1, x2});
    my = max({my, y1, y2});
    ix = min({ix, x1, x2});
    iy = min({iy, y1, y2});
  }
  if (abs(ix - mx) != abs(iy - my)) {
    cout << "NO" << '\n';
    return;
  }
  if (sum != abs(ix - mx) * 1ll * abs(ix - mx)) {
    cout << "NO" << '\n';
    return;
  }
  cout << "YES" << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
