def nestfor(n,sti,sti1,poj,j,prof,bene)
  if j == n-2
    for sj in 0..poj/sti[j]
      poj1 = poj - sj*sti[j]
      b = sj*(sti1[j]-sti[j]) + (poj1/sti[j+1])*(sti1[j+1]-sti[j+1])
      prof = bene+b if prof < bene+b
    end
  else
    if sti1[j]<sti[j]
      prof = nestfor(n,sti,sti1,poj,j+1,prof,bene)
    else
      for sj in 0..poj/sti[j]
        poj1 = poj - sj*sti[j]
        prof = nestfor(n,sti,sti1,poj1,j+1,prof,bene+sj*(sti1[j]-sti[j]))
      end
    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,0,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