def solve(p,dif,x)
    dp = Hash.new(-1)
    dp[0] = 0
    c = x
    p.size.times do |i|
        0.upto(c) do |j|
            next if dp[j] == -1
            next if j + p[i] > x
            dp[j+p[i]] = dp[j] + dif[i] if dp[j] + dif[i] > dp[j+p[i]]
        end
    end
    return dp.values.max + x
end
n, d, x = gets.split.map(&:to_i)
p = d.times.map{gets.split.map(&:to_i)}
dif = 1.upto(d-1).map{|i| n.times.map{|j| p[i][j] - p[i-1][j]}}
(d-1).times do |i|
    x = solve(p[i],dif[i],x)
end
p x