fun main(args: Array<String>) {
    val card = Array(3) {
        readLine()!!.split(" ").map(String::toInt)
    }
    val N = readLine()!!.toInt()
    val list = Array(N) {
        readLine()!!.toInt()
    }
    val score = Array(3) {
        BooleanArray(3)
    }
    for (i in list.indices) {
        val n = list[i]
        for (j in card.indices) {
            if (n == card[j][0]) {
                score[j][0] = true
            }
            if (n == card[j][1]) {
                score[j][1] = true
            }
            if (n == card[j][2]) {
                score[j][2] = true
            }
        }
    }
    if ((score[0][0] && score[0][1] && score[0][2])
        || (score[1][0] && score[1][1] && score[1][2])
        || (score[2][0] && score[2][1] && score[2][2])
        || (score[0][0] && score[1][0] && score[2][0])
        || (score[0][1] && score[1][1] && score[2][1])
        || (score[0][2] && score[1][2] && score[2][2])
        || (score[0][0] && score[1][1] && score[2][2])
        || (score[0][2] && score[1][1] && score[2][0])
    ) {
        println("Yes")
    } else {
        println("No")
    }
}