#include <bits/stdc++.h>
using namespace std;
int n;
int _x1[6], _x2[6], _y1[6], _y2[6];
bool b[6];
void dfs(int l) {
  if (l == n) {
    int minx1, maxx2, miny1, maxy2;
    minx1 = miny1 = 31401;
    maxx2 = maxy2 = -1;
    int area = 0;
    for (int i = 0; i < n; ++i) {
      if (b[i]) {
        minx1 = min(minx1, _x1[i]);
        miny1 = min(miny1, _y1[i]);
        maxx2 = max(maxx2, _x2[i]);
        maxy2 = max(maxy2, _y2[i]);
        area += (_y2[i] - _y1[i]) * (_x2[i] - _x1[i]);
      }
    }
    if (maxx2 - minx1 == maxy2 - miny1 &&
        area == (maxx2 - minx1) * (maxy2 - miny1)) {
      cout << "YES";
      exit(0);
    }
    return;
  }
  b[l] = true;
  dfs(l + 1);
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    _x1[i] = x1;
    _x2[i] = x2;
    _y1[i] = y1;
    _y2[i] = y2;
  }
  dfs(0);
  cout << "NO";
  return 0;
}
