fun main(args: Array<String>) {
    
    val a = listOf(
            readLine()!!.split(" ").map { it.toInt() },
            readLine()!!.split(" ").map { it.toInt() },
            readLine()!!.split(" ").map { it.toInt() }
    )
    val n = readLine()!!.toInt()
    val b = (1..n).map { readLine()!!.toInt() }
    
/*
    val a = listOf(
            listOf(84, 97, 66),
            listOf(79, 89, 11),
            listOf(61, 59, 7)
    )
 
    val n = 7
 
    val b = listOf(
            89,
            7,
            87,
            79,
            24,
            84,
            30
    )
    */
 
    val card = listOf(
            mutableListOf(false, false, false),
            mutableListOf(false, false, false),
            mutableListOf(false, false, false)
    )
 
    b.forEach { value ->
        val pos = findPos(a, value)
        pos?.let { (x, y) ->
            card[y][x] = true
        }
    }
 
    if (isBingo(card)) {
        println("Yes")
    } else {
        println("No")
    }
}
 
fun findPos(list: List<List<Int>>, findValue: Int): Pair<Int, Int>? {
    list.forEachIndexed { y, xlist ->
        val x = xlist.indexOfFirst { it == findValue }
 
        if (x != -1) {
            return Pair(x, y)
        }
    }
 
    return null
}
 
fun isBingo(card: List<List<Boolean>>): Boolean {
    val length = card.size
 
    // 横のチェック
    card.forEach { xlist ->
        if (xlist.none { !it }) return true
    }
 
    // 縦のチェック
    (0 until length).forEach { x ->
        if ((0 until length).map { y -> card[y][x] }.none { !it }) return true
    }
 
    // 斜めのチェック
    if ((0 until length).map { card[it][it] }.none { !it }) return true
    if ((0 until length).map { card[it][length - 1 - it] }.none { !it }) return true
 
    return false
}