#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, x1, x2, y1, y2, s = 0;
  int64_t mx1 = 31401, mx2 = -1, my1 = 31401, my2 = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    s = s + (x2 - x1) * (y2 - y1);
    if (x1 < mx1) mx1 = x1;
    if (x2 > mx2) mx2 = x2;
    if (y1 < my1) my1 = y1;
    if (y2 > my2) my2 = y2;
  }
  if (s == (mx2 - mx1) * (my2 - my1) && ((mx2 - mx1) == (my2 - my1)))
    cout << "YES";
  else
    cout << "NO";
}
