#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
} p1[10], p2[10];
struct S {
  point p1, p2;
  S() { p1.x = p2.x = p1.y = p2.y = -1; }
  void init() { p1.x = p2.x = p1.y = p2.y = -1; }
  int area() {
    int x = abs(p1.x - p2.x);
    int y = abs(p1.y - p2.y);
    return x * y;
  }
} s[10], t[10];
int cnt;
bool check() {
  S tmp;
  int sum = 0;
  for (int i = 0; i < cnt; ++i) {
    sum += t[i].area();
    if (tmp.p1.x == -1 || tmp.p1.x > t[i].p1.x) tmp.p1.x = t[i].p1.x;
    if (tmp.p1.y == -1 || tmp.p1.y > t[i].p1.y) tmp.p1.y = t[i].p1.y;
    if (tmp.p2.x == -1 || tmp.p2.x < t[i].p2.x) tmp.p2.x = t[i].p2.x;
    if (tmp.p2.y == -1 || tmp.p2.y < t[i].p2.y) tmp.p2.y = t[i].p2.y;
  }
  if (tmp.p2.y - tmp.p1.y != tmp.p2.x - tmp.p1.x) return 0;
  if (tmp.area() == sum) return 1;
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &s[i].p1.x, &s[i].p1.y, &s[i].p2.x, &s[i].p2.y);
    t[i] = s[i];
  }
  cnt = n;
  if (check()) {
    puts("YES");
    return 0;
  } else {
    puts("NO");
    return 0;
  }
  for (int i = 1; i < (1 << n); ++i) {
    cnt = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) t[cnt++] = s[j];
    }
    if (check()) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
