#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
const int N = 3010;
set<pair<int, int> > st;
int main() {
  int n;
  cin >> n;
  long long ret = 0;
  long long lx = inf, rx = 0, ly = inf, ry = 0;
  for (int i = 0; i < n; i++) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    lx = min(lx, x1);
    ly = min(ly, y1);
    rx = max(rx, x2);
    ry = max(ry, y2);
    long long t = (x2 - x1) * (y2 - y1);
    ret += t;
  }
  bool f = 1;
  if (rx - lx != ry - ly) f = 0;
  if ((rx - lx) * (ry - ly) != ret) f = 0;
  if (f)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
