#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long s1 = 0, s2 = 0;
  int maxx = 0, minx = 31400, maxy = 0, miny = 31400;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 < minx) minx = x1;
    if (x2 > maxx) maxx = x2;
    if (y1 < miny) miny = y1;
    if (y2 > maxy) maxy = y2;
    s1 += (x2 - x1) * (y2 - y1);
  }
  s2 = (maxx - minx) * (maxy - miny);
  if ((maxx - minx) == (maxy - miny) && s1 == s2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
