fun main(args: Array<String>) {
    val lineOne = readLine()!!.split(" ").map { it.toInt() }
    val lineTwo = readLine()!!.split(" ").map { it.toInt() }
    val lineThree = readLine()!!.split(" ").map { it.toInt() }
    val number = readLine()!!.toInt()
    val numberList: MutableList<Int> = mutableListOf()
    for (i in 1..number){
        numberList.add(readLine()!!.toInt())
    }
    val cardList: MutableList<Int> = mutableListOf()
    lineOne.forEach {
        cardList.add(it)
    }
    lineTwo.forEach {
        cardList.add(it)
    }
    lineThree.forEach {
        cardList.add(it)
    }
    val isBingo: MutableList<Boolean> = mutableListOf()
    cardList.forEach { it ->
        val n = it
        var isB = false
        numberList.forEach {
            if (n == it) {
                isB = true
            }
        }
        if (isB) {
            isBingo.add(true)
        }else{
            isBingo.add(false)
        }
    }
    if (isBingo[0] && isBingo[1] && isBingo[2]){
        println("Yes")
        return
    }else if (isBingo[3] && isBingo[4] && isBingo[5]){
        println("Yes")
        return
    }else if (isBingo[6] && isBingo[7] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[0] && isBingo[3] && isBingo[6]){
        println("Yes")
        return
    }else if (isBingo[1] && isBingo[4] && isBingo[7]){
        println("Yes")
        return
    }else if (isBingo[2] && isBingo[5] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[0] && isBingo[4] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[2] && isBingo[4] && isBingo[6]){
        println("Yes")
        return
    }else{
        println("No")
    }



}