#include <bits/stdc++.h>
using namespace std;
const int MAX = 62800 << 1;
int mnX = MAX, mxX, mnY = MAX, mxY;
pair<pair<int, int>, pair<int, int> > R[5];
int Y[MAX + 1];
int first = 1;
bool valid(int x, int y1, int y2) {
  if (Y[y1] == -1 && !first) return 0;
  for (int y = y1 + 1; y < y2; y++)
    if (Y[y] != -1 && Y[y] != x)
      return 0;
    else if (Y[y] == -1 && x != mnX)
      return 0;
  return 1;
}
bool cover(int x, int y1, int y2) {
  for (int y = y1; y <= y2; y++) Y[y] = x;
}
int main() {
  memset(Y, -1, sizeof Y);
  int n, a, b, c, d;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a >> b >> c >> d;
    a <<= 1, b <<= 1, c <<= 1, d <<= 1;
    R[i] = make_pair(make_pair(a, b), make_pair(c, d));
    mnX = min(mnX, a);
    mnY = min(mnY, b);
    mxX = max(mxX, c);
    mxY = max(mxY, d);
  }
  if (mxX - mnX != mxY - mnY) {
    puts("NO");
    return 0;
  }
  sort(R, R + n);
  for (int i = 0; i < (n); i++) {
    if (!valid(R[i].first.first, R[i].first.second, R[i].second.second)) {
      puts("NO");
      return 0;
    }
    cover(R[i].second.first, R[i].first.second, R[i].second.second);
    first = 0;
  }
  int x = Y[mnY];
  for (int y = (mnY); y <= (mxY); y++)
    if (Y[y] != x) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
