object Main extends App {
    val map = Seq(1, 3, -1, 2, 4, 5, 1, -1, 5, 3, 3, 1).grouped(2).toSeq.lift
    for (p <- io.Source.stdin.getLines if p != "#") {
        val x = p.foldLeft(0)((c, w) => map(c) match {
            case None => -1
            case Some(next) => next(w.asDigit)
        })
        if (x == 5) println("Yes")
        else println("No")
    }
}