#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int N = 1e6 + 7;
int main() {
  int n;
  cin >> n;
  int x1[n], x2[n], y1[n], y2[n];
  int minx = INT_MAX, maxx = INT_MIN, miny = INT_MAX, maxy = INT_MIN;
  for (long long i = 0; i < (int)n; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    minx = min(minx, x1[i]);
    maxx = max(maxx, x2[i]);
    miny = min(miny, y1[i]);
    maxy = max(maxy, y2[i]);
  }
  if (maxx - minx != maxy - miny) {
    cout << "NO";
  } else {
    bool flag = true;
    for (long long i = 0; i < (int)n; i++) {
      if (x2[i] != maxx) {
        for (long long j = y1[i]; j < (int)y2[i] + 1; j++) {
          bool flag1 = false;
          for (long long k = 0; k < (int)n; k++) {
            if (x1[k] == x2[i] && y1[k] <= j && y2[k] >= j) flag1 = true;
          }
          if (!flag1) flag = false;
        }
      }
      if (y2[i] != maxy) {
        for (long long j = x1[i]; j < (int)x2[i] + 1; j++) {
          bool flag1 = false;
          for (long long k = 0; k < (int)n; k++) {
            if (y1[k] == y2[i] && x1[k] <= j && x2[k] >= j) flag1 = true;
          }
          if (!flag1) flag = false;
        }
      }
    }
    if (flag)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
