#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x1 = INT_MAX, y1 = INT_MAX, x2 = 0, y2 = 0;
  long area = 0;
  for (int i = 0; i < (n); ++i) {
    int a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;
    area += (a2 - a1) * (b2 - b1);
    x1 = min(a1, x1);
    x1 = min(a2, x1);
    y1 = min(b1, y1);
    y1 = min(b2, y1);
    x2 = max(a2, x2);
    x2 = max(a1, x2);
    y2 = max(b2, y2);
    y2 = max(b1, y2);
  }
  cout << ((x2 - x1) == (y2 - y1) && area == (x2 - x1) * (y2 - y1) ? "YES"
                                                                   : "NO")
       << endl;
  return 0;
}
