
fun main(args: Array<String>) {
    val bingo = (1..3).map {
        readLine()!!.split(" ").map(String::toInt)
    }
    val N = readLine()!!.toInt()
    val lottery = (1..N).map {
        readLine()!!.toInt()
    }
    val isHitted = bingo.map { row ->
        row.map { b ->
            b in lottery
        }
    }
    val rowHitted = isHitted.map { row ->
        row.all {b -> b}
    }.any { it }
    val colHitted = (0..2).map { i -> 
        (0..2).map { j -> 
            isHitted[j][i]
        }.all { it }
    }.any { it }
    val leftNanameHitted = listOf(Pair(0,0), Pair(1,1), Pair(2,2)).map { 
        val (i, j) = it
        isHitted[i][j]
    }.all { it }
    val rightNanameHitted = listOf(Pair(0,2), Pair(1,1), Pair(2,0)).map { 
        val (i, j) = it
        isHitted[i][j]
    }.all { it }
    if(rowHitted || colHitted || leftNanameHitted || rightNanameHitted) { "Yes" }  else  { "No" }.run(::println)
}
