#include <bits/stdc++.h>
using namespace std;
const int NMAX = 31400;
struct point {
  int x, y;
};
int n;
pair<point, point> p[5];
bool used[5];
bool func() {
  long long s = 0;
  point MIN, MAX;
  MIN.x = MIN.y = NMAX;
  MAX.x = MAX.y = 0;
  for (int i = 0; i < n; i++) {
    s += (p[i].second.x - p[i].first.x) * (p[i].second.y - p[i].first.y);
    MIN.x = min(MIN.x, p[i].first.x);
    MIN.y = min(MIN.y, p[i].first.y);
    MAX.x = max(MAX.x, p[i].second.x);
    MAX.y = max(MAX.y, p[i].second.y);
  }
  if ((MAX.x - MIN.x) == (MAX.y - MIN.y) && s == pow(MAX.x - MIN.x, 2)) {
    return true;
  }
  return false;
}
int main() {
  cin >> n;
  pair<int, int> a, b, MAX, MIN;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first.x >> p[i].first.y >> p[i].second.x >> p[i].second.y;
  }
  if (func())
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
