def nestfor(n,s,sti,sti1,poj,j)
  if j == n-2
    prof = 0
    for sj in 0..poj/sti[j]
      poj1 = poj - sj*sti[j]
      s[j] = sj
      s[j+1] = poj1/sti[j+1]
      bene = s.map.with_index{|int,idx| int*(sti1[idx]-sti[idx])}.inject(:+)
      prof = bene if prof < bene
    end
  else
    for sj in 0..poj/sti[j]
      poj1 = poj - sj*sti[j]
      s[j] = sj
      prof = nestfor(n,s,sti,sti1,poj1,j+1)
    end
  end
  prof
end
  
n,d,x = gets.split(" ").map{|str| str.to_i}

stock = Array.new(d){gets.split(" ").map{|str| str.to_i}} #i??\??????????????????i??????????¨????

if n>=2
  for i in 0..d-2
    x += nestfor(n,[],stock[i],stock[i+1],x,0)
  end
else
  for i in 0..d-2
    si1,si = stock[i+1][0],stock[i][0]
    x += (si1-si)*(x/si) if si1 > si
  end
end

puts x