import io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val ds = for (i <- 1 to n) yield readLine.split(' ')

  val result = ds.sliding(3).exists(_.forall(d => d.head == d.last))
  if (result) println("Yes")
  else println("No")
}