def solve(p,dif,x)
    dp = Array.new(10).map{Hash.new(0)}
    dp[0] = {0 => 0}
    p.size.times do |i|
        dp[i].each do |k,v|
            j = k
            add = 0
            while j <= x
                dp[i+1][j] = dp[i][k] + add if dp[i][k] + add >= dp[i+1][j]
                j += p[i]
                add += dif[i]
            end
        end
    end
    return dp[p.size].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