#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = -1, y = -1;
  int lx = 100000, ly = 100000;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cnt += (c - a) * (d - b);
    x = max(x, c);
    y = max(y, d);
    lx = min(lx, a);
    ly = min(ly, b);
  }
  string result = "NO";
  if (x - lx == y - ly && (x - lx) * (y - ly) == cnt) result = "YES";
  cout << result << endl;
}
