fun main(args: Array<String>) {

    val bingo = Array(3) { readLine()!!.split(" ").map(String::toInt) }
    val input = Array(readLine()!!.toInt()) {
        readLine()!!.toInt()
    }

    var flg = false
    for (h in 0..2) {
        flg = flg || bingo[h].all { input.contains(it) }
    }

    for (w in 0..2) {
        flg = flg || intArrayOf(bingo[0][w], bingo[1][w], bingo[2][w]).all { input.contains(it) }
    }

    flg = flg || intArrayOf(bingo[0][0], bingo[1][1], bingo[2][2]).all { input.contains(it) }
    flg = flg || intArrayOf(bingo[2][0], bingo[1][1], bingo[0][2]).all { input.contains(it) }
    if (flg) {
        println("Yes")
    } else {
        println("No")
    }
}



