fun main(arr:Array<String>) {
    val card = (0..2).map { readLine()!!.split(" ").map { it.toInt() } }
    val check = (0..2).map { (0..2).map { false }.toMutableList() }
    val logCount = readLine()!!.toInt()
    val log = (1..logCount).map { readLine()!!.toInt() }
    log.forEach {num ->
        (0..2).forEach{rowIndex ->
            (0..2).forEach { colIndex ->
                if(card[rowIndex][colIndex] == num) {
                    check[rowIndex][colIndex] = true
                }
            }
        }
    }
    var isBingo = (0..2).any { idx->
        check[idx].all { it }
    }
    isBingo = isBingo || (0..2).any { idx ->
        check.map { it[idx] }.all { it }
    }
    isBingo = isBingo || (0..2).all { check[it][it] }
    isBingo = isBingo || (0..2).all { check[it][2-it] }
    println(if(isBingo) "Yes" else "No")
}