#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a1, b1, a2, b2;
  a1 = b1 = 0xfffffff;
  a2 = b2 = -0xfffffff;
  long long s = 0;
  for (int i = 0; i < n; i++) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    a1 = min(a1, x1);
    b1 = min(b1, y1);
    a2 = max(a2, x2);
    b2 = max(b2, y2);
    s += (x2 - x1) * (y2 - y1);
  }
  long long need = (a2 - a1) * (b2 - b1);
  if (s == need && (a2 - a1) == (b2 - b1))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
