fun main(args: Array<String>) {
    val A = Array(3) { listOfInt() }
    val N = nextInt()
    val B = Array(N) { nextInt() }
    val F = Array(3) { BooleanArray(3) }
    B.forEach { b ->
        repeat(3) { i ->
            repeat(3) { j ->
                if (A[i][j] == b) F[i][j] = true
            }
        }
    }
    var ans = false
    for (i in 0 until 3) {
        ans = ans or (F[i][0] and F[i][1] and F[i][2])
    }
    for (j in 0 until 3) {
        ans = ans or (F[0][j] and F[1][j] and F[2][j])
    }
    ans = ans or (F[0][0] and F[1][1] and F[2][2])
    ans = ans or (F[0][2] and F[1][1] and F[2][0])
    println(if (ans) "Yes" else "No")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
