#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n, x, y, X, Y, s = 0, S, minX, maxX, minY, maxY;
  minX = minY = 31401;
  maxX = maxY = 0;
  cin >> n;
  while (n--) {
    cin >> x >> y >> X >> Y;
    s += (X - x) * (Y - y);
    if (minX > x) minX = x;
    if (minY > y) minY = y;
    if (maxX < X) maxX = X;
    if (maxY < Y) maxY = Y;
  }
  S = (maxY - minY) * (maxX - minX);
  if (maxX - minX == maxY - minY && S == s)
    cout << "YES";
  else
    cout << "NO";
  return EXIT_SUCCESS;
}
