private fun solve(): String { val d = readInts() val seen = mutableSetOf() var collisions = false repeat(readInt()) { val s = readLn().map { d[it - 'A'] }.joinToString("") if (!seen.add(s)) collisions = true } return if (collisions) "YES" else "NO" } fun main() { // System.setIn(java.io.File("input.txt").inputStream()) // System.setOut(java.io.PrintStream("output.txt")) repeat(readInt()) { println("Case #${it + 1}: ${solve()}") } } private fun readLn() = readLine()!! private fun readInt() = readLn().toInt() private fun readStrings() = readLn().split(" ") private fun readInts() = readStrings().map { it.toInt() }