fun main(args: Array<String>) {
    val n = 9
    val a = Array<Int>(n, {0})

    for(i in 0..2) {
        val (n1, n2, n3) = readLine()!!.split(" ")
        a[0 + i * 3] = n1.toInt()
        a[1 + i * 3] = n2.toInt()
        a[2 + i * 3] = n3.toInt()
    }

    val p1 = listOf(a[0], a[1], a[2])
    val p2 = listOf(a[3], a[4], a[5])
    val p3 = listOf(a[6], a[7], a[8])
    val p4 = listOf(a[0], a[3], a[6])
    val p5 = listOf(a[1], a[4], a[7])
    val p6 = listOf(a[2], a[5], a[8])
    val p7 = listOf(a[0], a[4], a[8])
    val p8 = listOf(a[2], a[4], a[6])

    val bingo = listOf(p1, p2, p3, p4, p5, p6, p7, p8)

    val inputN = readLine()!!.toInt()
    val b = Array<Int>(inputN, {0})
    for(i in 0..inputN - 1) {
        val num = readLine()!!.toInt()
        b[i] = num
    }

    for(i in 0..7) {
        if(b.toList().containsAll(bingo[i])) {
            println("Yes")
            return;
        }
    }

    println("No")
}