fun main(args: Array) { val ans = if(isMuteki()) "YES" else "NO" print(ans) } fun isMuteki():Boolean { val n = readLine()!!.toInt() val log1 = (1..n).map { readLine()!! } val log = log1.map { it.split(" ").map { it.toInt()-1 } } val map = Array(9){ arrayOfNulls(9)} val koma = mutableListOf(Koma(0,1,7), Koma(1,2,8), Koma(2, 6,8)) koma.forEach { map[it.y][it.x] = it } log.forEach { val (fromX, fromY, toX, toY) = it val k = map[fromY][fromX]?:(Koma(koma.size, fromX, fromY).also { koma.add(it) }) map[fromY][fromX] = null k.y = toY k.x = toX map[toY][toX] = k } return (map[7][4]?.id ?: -1) == 0 && (map[7][3]?.id ?: -1) == 1 && (map[7][5]?.id ?: -1) == 2 } class Koma(val id:Int, var x:Int = 0, var y:Int = 0)