#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) { return a + b - max(a, b); }
int main() {
  int n;
  cin >> n;
  int x1[n], y1[n], x2[n], y2[n];
  int minx = 31400, maxx = 0, miny = 31400, maxy = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (y1[i] > y2[i]) swap(y1[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) return cout << "NO", 0;
  for (int x = minx; x < maxx; ++x) {
    int y = maxy - miny;
    for (int i = 0; i < n; ++i) {
      if ((x1[i] <= x) && (x < x2[i])) y -= (y2[i] - y1[i]);
    }
    if (y > 0) return cout << "NO", 0;
  }
  cout << "YES";
}
