#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x1, x2, y1, y2, mx = 0, my = 0, sum = 0, mnx = 100000000,
                         mny = 100000000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    mx = max(mx, max(x1, x2));
    my = max(my, max(y1, y2));
    mnx = min(mnx, min(x1, x2));
    mny = min(mny, min(y1, y2));
    sum += ((x2 - x1) * (y2 - y1));
  }
  int x = mx - mnx;
  int y = my - mny;
  if (x == y) {
    int A = x * y;
    if (sum == A)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
