fun main(args:Array<String>):Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val matrix = Array(n){readLine()!!.trim().split(' ').map(String::toInt).toIntArray()}
        val min = matrix.mapIndexed { index, ints ->
            val m = ints.min()!!
            ints.indices.filter{ints[it] == m}.map{Point(it, index)}
        }.flatten()
        val max = (0 until n).flatMap{x ->
            val m = (0 until n).map{matrix[it][x]}.max()!!
            (0 until n).filter{matrix[it][x] == m}.map{Point(x, it)}
        }
        println(min.filter{max.contains(it)}.map{matrix[it.y][it.x]}.max() ?: 0)
    }
}
data class Point(val x:Int, val y:Int)
