#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x, y, xx, yy;
  long long s = 0;
  int X = 1001001001, Y = 1001001001, XX = 0, YY = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y >> xx >> yy;
    s += abs(xx - x) * abs(yy - y);
    X = min(X, x);
    Y = min(Y, y);
    XX = max(XX, xx);
    YY = max(YY, yy);
  }
  if (abs(X - XX) * abs(Y - YY) == s && abs(X - XX) == abs(Y - YY))
    cout << "YES";
  else
    cout << "NO";
}
