fun main (args : Array<String>) {
    val line1 = readLine()!!.split(" ")
    val line2 = readLine()!!.split(" ")
    val line3 = readLine()!!.split(" ")

    val n = readLine()!!.toInt()
    var bList : MutableList<Int> = mutableListOf()
    for (i in 0..n - 1) {
        val b = readLine()!!.toInt()
        bList.add(b)
    }

    var aMap : MutableMap<Int, Boolean> = mutableMapOf()
    var aList : MutableList<Int> = mutableListOf()

    for (i in line1) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }
    for (i in line2) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }
    for (i in line3) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }

    for (i in 0..bList.size - 1) {
        if (aMap.containsKey(bList[i])) {
            aMap.put(bList[i], true)
        } else {
            continue
        }
    }

    if ( (aMap[aList[0]]!! && aMap[aList[3]]!! && aMap[aList[6]]!!) || (aMap[aList[1]]!! && aMap[aList[4]]!! && aMap[aList[7]]!!) || 
        (aMap[aList[2]]!! && aMap[aList[5]]!! && aMap[aList[8]]!!) || (aMap[aList[0]]!! && aMap[aList[1]]!! && aMap[aList[2]]!!) || 
        (aMap[aList[3]]!! && aMap[aList[4]]!! && aMap[aList[5]]!!) || (aMap[aList[6]]!! && aMap[aList[7]]!! && aMap[aList[8]]!!) || 
        (aMap[aList[0]]!! && aMap[aList[4]]!! && aMap[aList[8]]!!) || (aMap[aList[2]]!! && aMap[aList[4]]!! && aMap[aList[6]]!!) ) {
        println("Yes")
    } else {
        println("No")
    }

}