#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  long long s2 = 0;
  long long mx, my, Mx, My;
  vector<long long> x1(n), y1(n), x2(n), y2(n);
  for (int i = 0; i < n; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    s2 += (x2[i] - x1[i]) * (y2[i] - y1[i]);
  }
  mx = x1[0];
  my = y1[0];
  Mx = x2[0];
  My = y2[0];
  for (int i = 0; i < n; i++) {
    mx = min(x1[i], mx);
    my = min(y1[i], my);
    Mx = max(x2[i], Mx);
    My = max(y2[i], My);
  }
  if ((Mx - mx) != (My - my))
    cout << "NO";
  else if ((Mx - mx) * (My - my) == s2)
    cout << "YES";
  else
    cout << "NO";
}
