#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ar = 0;
  long long tx1 = 31401, tx2 = -1, ty1 = 31401, ty2 = -1;
  long long x1, x2, y1, y2;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    ar += (x2 - x1) * (y2 - y1);
    if (tx2 < x2) tx2 = x2;
    if (ty2 < y2) ty2 = y2;
    if (tx1 > x1) tx1 = x1;
    if (ty1 > y1) ty1 = y1;
  }
  if ((tx2 - tx1) != (ty2 - ty1) || ar != (tx2 - tx1) * (ty2 - ty1))
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
