fun main(args: Array<String>) {
    data class Spot(val number: String, var isOpen: Boolean = false)

    fun isBingo(spots: List<List<Spot>>): Boolean {
        // 横
        spots.forEach {
            if (it.all { it.isOpen }) {
                return true
            }
        }
        // 縦
        0.until(3).forEach {
            if (spots[0][it].isOpen && spots[1][it].isOpen && spots[2][it].isOpen) {
                return true
            }
        }
        // 斜め
        if (spots[0][0].isOpen && spots[1][1].isOpen && spots[2][2].isOpen) {
            return true
        }
        if (spots[0][2].isOpen && spots[1][1].isOpen && spots[2][0].isOpen) {
            return true
        }

        return false
    }

    val spots = 0.until(3).map {
        readLine()?.split(" ")?.map { Spot(it, false) } ?: return@main
    }
    val n = readLine()?.toInt() ?: return
    val numbers = 0.until(n).map {
        readLine() ?: return@main
    }
    numbers.forEachIndexed { i, number ->
        spots.forEach { line ->
            line.forEach { spot ->
                if (spot.number == number) {
                    spot.isOpen = true
                }
            }
        }
        if (isBingo(spots)) {
            println("Yes")
            return
        }
    }
    println("No")
}
