object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  case class Rect(x1: Int, y1: Int, x2: Int, y2: Int) {
    def area = (x2 - x1).toLong * (y2 - y1)
  }

  def solve(): Unit = {
    val N = ni()
    val R = map(N){ _ =>
      val x1, y1, x2, y2 = ni()
      Rect(x1, y1, x2, y2)
    }

    val l = R.map(_.x1).min
    val r = R.map(_.x2).max
    val b = R.map(_.y1).min
    val t = R.map(_.y2).max

    val w = r - l
    val h = t - b

    val sqr = Rect(l, b, r, t)
    val isSqr = w > 0 && w == h &&
      R.map(_.area).sum == sqr.area

    if (isSqr) out.println("YES")
    else out.println("NO")
  }

  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


import scala.math._

object FlippingGame extends App {
  import Scanner._

  val n = readInt
  val seq = Array.fill(n)(readInt)

  var max = -1
  for(i <- 0 until n) {
    var total = 0
    for(j <- i until n; v = seq(j)) {
      if(v == 0) {
        total += 1
        if(total > max)
          max = total
      } else
        total -= 1
    }
  }
  println(seq.sum + max)
}

object Scanner {
  def readInt() = {
    var acc = 0
    readWith {
      case c if c >= '0' && c <= '9' && (Int.MaxValue - acc) >= (c - '0') =>
        acc = (acc * 10) + (c - '0')
    }
    acc
  }
  def readLong() = {
    var acc = 0L
    readWith {
      case c if c >= '0' && c <= '9' && (Long.MaxValue - acc) >= (c - '0') =>
        acc = (acc * 10L) + (c - '0')
    }
    acc
  }
  def readDouble() = {
    var (acc, frac, fracPow, readFrac) = (0L, 0L, 1L, false)
    readWith {
      case c if c >= '0' && c <= '9' && !readFrac && (Long.MaxValue - acc) >= (c - '0') =>
        acc = (acc * 10) + (c - '0')
      case c if c >= '0' && c <= '9' && readFrac && (Long.MaxValue - frac) >= (c - '0') =>
        frac = (frac * 10) + (c - '0')
        fracPow *= 10
      case c if c == '.' && !readFrac =>
        readFrac = true
    }
    acc + (frac.toDouble / fracPow)
  }
  def readString() = {
    var string = new StringBuilder
    readWith { case c => string += c }
    string
  }
  def readLine() = Console.in.readLine()
  def readChar() = Console.in.read().toChar
  def readWith(func: PartialFunction[Char, Unit]) {
    val handler = func orElse[Char, Unit] {
      case _ => throw new java.io.IOException("unexpected token")
    }

    var c = readChar
    while(c.isWhitespace)
      c = readChar

    while(!c.isWhitespace) {
      handler(c)

      c = readChar
    }
  }
}


import scala.io.Source

object Solution extends App {
  val in = Source.stdin.getLines()
  val n = in.next().toInt
  val data = in.next().split(' ').map(_.toInt).distinct.sorted
  if (data.length > 2 && data.sliding(3).exists{case Array(a, b, c) => c == a + 2})
    println("YES")
  else
    println("NO")
}


object A471 extends App {
    // val sticks = scala.io.StdIn.readLine.split(' ').map(_.toInt)
    val sticks = new Array[Int](6)
    val cnt = new Array[Int](10)

    val cin = new java.util.Scanner(System.in)

    for (i <- 0 until 6)
        sticks(i) = cin.nextInt

    for (i <- sticks) cnt(i) += 1

    if (cnt.max < 4) println("Alien")
    else {
        val criteria = cnt.filter(x => x != 0 && x != 4)(0) % 2
        println(
            criteria match {
                case 0 => "Elephant"
                case 1 => "Bear"
            })
    }
}


object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  val data = (1 to n).map(_ => in.next().split(' ').map(_.toInt))
  if (n == 1)
    println(-1)
  else if (n == 3 || n == 4) {
    val min = data.map(_.head).min
    val max = data.map(_.head).max
    val miny = data.map(_.last).min
    val maxy = data.map(_.last).max
    println((maxy - miny) * (max - min))
  } else {
    val min = data.map(_.head).min
    val max = data.map(_.head).max
    val miny = data.map(_.last).min
    val maxy = data.map(_.last).max
    if (min != max && miny != maxy)
      println((maxy - miny) * (max - min))
    else
      println(-1)
  }
}