#include <bits/stdc++.h>
using namespace std;
bool S[4][31401];
int m, maxx = -1, maxy = -1, minx = 31401, miny = 31401, n, s1, s2, x, y;
vector<int> X, Y;
int main() {
  scanf("%d", &n);
  m = n + n;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    X.push_back(x);
    Y.push_back(y);
    if (X[i] < minx) minx = X[i];
    if (X[i] > maxx) maxx = X[i];
    if (Y[i] < miny) miny = Y[i];
    if (Y[i] > maxy) maxy = Y[i];
    if (i & 1) s1 += (X[i] - X[i - 1]) * (Y[i] - Y[i - 1]);
  }
  x = maxx - minx;
  y = maxy - miny;
  s2 = x * y;
  if (s1 != s2 || x != y) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < m; i += 2) {
    if (X[i] == minx) {
      for (int j = Y[i]; j <= Y[i + 1]; j++) S[3][j] = true;
    }
    if (Y[i] == miny) {
      for (int j = X[i]; j <= X[i + 1]; j++) S[2][j] = true;
    }
    if (X[i + 1] == maxx) {
      for (int j = Y[i]; j <= Y[i + 1]; j++) S[1][j] = true;
    }
    if (Y[i + 1] == maxy) {
      for (int j = X[i]; j <= X[i + 1]; j++) S[0][j] = true;
    }
  }
  for (int j = minx; j <= maxx; j++) {
    if (!S[0][j] || !S[2][j]) {
      puts("NO");
      return 0;
    }
  }
  for (int j = miny; j <= maxy; j++) {
    if (!S[1][j] || !S[3][j]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
