#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, x1, x2, y1, y2, ans = 0, mn1 = 1e9, mx1 = 0, mn2 = 1e9, mx2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    ans += (abs(x1 - x2) * abs(y1 - y2));
    mn1 = min(mn1, x1);
    mx1 = max(mx1, x2);
    mn2 = min(mn2, y1);
    mx2 = max(mx2, y2);
  }
  long long l, w;
  l = abs(mx1 - mn1);
  w = abs(mx2 - mn2);
  if (ans == l * w && l == w)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int I = 1; I <= t; I++) {
    solve();
  }
  return 0;
}
