#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, y1, x2, y2, left, right, top, bottom;
  long long int s = 0, square = 0;
  cin >> n;
  if (n == 1) {
    cin >> x1 >> y1 >> x2 >> y2;
    if ((x2 - x1) == (y2 - y1))
      cout << "YES";
    else
      cout << "NO";
  } else {
    left = bottom = 31401;
    right = top = -1;
    for (int i = 0; i < n; i++) {
      cin >> x1 >> y1 >> x2 >> y2;
      s += ((x2 - x1) * (y2 - y1));
      if (x1 < left) left = x1;
      if (x2 > right) right = x2;
      if (y1 < bottom) bottom = y1;
      if (y2 > top) top = y2;
    }
    int rl = (right - left);
    int tb = (top - bottom);
    square = rl * tb;
    if ((s == square) && (rl == tb))
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
