object Main extends App{
    val a = for(_ <- 1 to 3) yield scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val b = for(_ <- 1 to scala.io.StdIn.readInt) yield scala.io.StdIn.readInt
    val a_series = a.reduce(_ ++: _)
    val hit = for(count <- a_series) yield b.contains(count)
    val yoko = hit.grouped(3).map(e1 => e1.forall(e2 => e2 == true)).reduce(_ || _)
    val tate = (0 to 6 by 3).map(hit(_)).forall(_ == true) || (1 to 7 by 3).map(hit(_)).forall(_ == true) || (2 to 8 by 3).map(hit(_)).forall(_ == true)
    val name = (0 to 8 by 4).map(hit(_)).forall(_ == true) || (2 to 6 by 2).map(hit(_)).forall(_ == true)
    if(yoko || tate || name) println("Yes") else println("No")
}