fun main(args: Array<String>?): Unit {
    val money = IntArray(100001){0}
    val (n, d, x) = readLine()!!.trim().split(' ').map(String::toInt)
    var current = x
    val prices = List(d){ readLine()!!.trim().split(' ').map(String::toInt)}
    for (i in 1 until d) {
        money.fill(-1)
        for (j in 0 .. current) money[j] = j
        for (p in 0 until n) {
            if (prices[i][p] > prices[i - 1][p]) for (j in prices[i - 1][p] .. current) {
                if (money[j - prices[i - 1][p]] + prices[i][p] > money[j]) {
                    money[j] = money[j - prices[i - 1][p]] + prices[i][p]
                }
            }
        }
        current = money[current]
    }
    println(current)
}

