#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, y1, x2, y2, t = 1 << 20, l = 1 << 20, r = -1, b = -1, ars = 0;
  cin >> n;
  for (int i = (0), _e = (n); i < _e; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    ars += abs((x1 - x2) * (y1 - y2));
    t = min(y1, t);
    l = min(x1, l);
    r = max(x2, r);
    b = max(y2, b);
  }
  if (abs((t - b) * (l - r)) == ars && abs(t - b) == abs(l - r))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
