#include <bits/stdc++.h>
using namespace std;
void setIO(string name) {
  string in_f = name + ".in";
  string out_f = name + ".out";
  freopen(in_f.c_str(), "r", stdin);
  freopen(out_f.c_str(), "w", stdout);
}
int n;
int c[10][4];
void init() {
  cin >> n;
  for (int i = 1; i <= (n); ++i)
    scanf("%d %d %d %d", c[i] + 0, c[i] + 1, c[i] + 2, c[i] + 3);
}
void solve() {
  int x1, y1, x2, y2;
  x1 = y1 = -1, x2 = y2 = 32767;
  for (int i = 1; i <= (n); ++i) {
    for (int j = 0; j < (4); ++j) {
      if (j & 1)
        y1 = max(y1, c[i][j]), y2 = min(y2, c[i][j]);
      else
        x1 = max(x1, c[i][j]), x2 = min(x2, c[i][j]);
    }
  }
  if (x1 - x2 != y1 - y2) {
    puts("NO");
    return;
  }
  int s = (x1 - x2) * (y1 - y2);
  for (int i = 1; i <= (n); ++i) s -= (c[i][2] - c[i][0]) * (c[i][3] - c[i][1]);
  if (s == 0)
    puts("YES");
  else
    puts("NO");
}
int main() {
  init();
  solve();
  return 0;
}
