#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b, c, d, e, f, g, h, s;
int main() {
  cin >> n;
  a = 10000000;
  b = 10000000;
  for (int i = 0; i < n; i++) {
    cin >> e >> f >> g >> h;
    a = min(a, e);
    b = min(b, f);
    c = max(c, g);
    d = max(d, h);
    s += (g - e) * (h - f);
  }
  if ((s == (c - a) * (d - b)) && (c - a == d - b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
