#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ln, lk, lm;
vector<pair<int, int>> vp;
int ss, a, b, c, d;
bool ck() {
  a = (1 << 30);
  b = (1 << 30);
  c = -((1 << 30));
  d = -((1 << 30));
  for (auto p : vp) {
    a = min(a, p.first);
    b = min(b, p.second);
    c = max(c, p.first);
    d = max(d, p.second);
  }
  int x = c - a;
  int y = d - b;
  if (x != y || x * y != ss) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    vp.push_back({a, b});
    vp.push_back({c, d});
    ss += abs(a - c) * abs(b - d);
  }
  sort(vp.begin(), vp.end());
  puts(ck() ? "YES" : "NO");
  return 0;
}
