#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long S = 0;
  long long X1 = 100000, Y1 = 100000, X2 = -100000, Y2 = -100000;
  for (int(i) = (0); (i) < (n); ++(i)) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    S += (y2 - y1) * (x2 - x1);
    X1 = min(X1, x1);
    X2 = max(X2, x2);
    Y1 = min(Y1, y1);
    Y2 = max(Y2, y2);
  }
  if (S == (Y2 - Y1) * (X2 - X1) && (Y2 - Y1) == (X2 - X1))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
