#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    int a, b, c, d, sum = 0, i = 0, mx = -1, my = -1, mix = N, miy = N;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c >> d;
      sum += abs(a - c) * abs(d - b);
      mx = max(mx, max(a, c));
      my = max(my, max(d, b));
      mix = min(mix, min(a, c));
      miy = min(miy, min(d, b));
    }
    if (((mx - mix) != (my - miy)) || (mx - mix) * (my - miy) != sum)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
