### main

loop do
  c, d, w, x = gets.split.map(&:to_i)
  break if (c | d | w | x) == 0

  es = c.times.map{gets.split.map(&:to_i)}
  fs = c.times.map{gets.split.map(&:to_i)}
  #p es
  #p fs

  dp = (d + 1).times.map{(w + 1).times.map{(x + 1).times.map{-100000}}}
  dp[0][0][0] = 0

  for i in (0...d)
    for j in (0..w)
      for k in (0..x)
        dpijk = dp[i][j][k]
        next if dpijk < 0

        dp[i + 1][j][k] = dpijk if dp[i + 1][j][k] < dpijk

        for r in (0...c)
          next if es[r][i] == 0
          j0 = j + fs[r][i]
          if j0 <= w
            dp0 = dpijk + es[r][i]
            dp[i + 1][j0][k] = dp0 if dp[i + 1][j0][k] < dp0

            next if k == x

            dp1 = dp0
            j1 = j0

            (r + 1).upto(c - 1) do |r1|
              break if es[r1][i] == 0
              dp1 += es[r1][i]
              j1 += fs[r1][i]
              break if j1 > w
              dp[i + 1][j1][k + 1] = dp1 if dp[i + 1][j1][k + 1] < dp1
            end

            dp1 = dp0
            j1 = j0

            (r - 1).downto(0) do |r1|
              break if es[r1][i] == 0
              dp1 += es[r1][i]
              j1 += fs[r1][i]
              break if j1 > w
              dp[i + 1][j1][k + 1] = dp1 if dp[i + 1][j1][k + 1] < dp1
            end
          end
        end
      end
    end
  end

  max_dp = 0
  for j in (0..w)
    for k in (0..x)
      dpdjk = dp[d][j][k]
      max_dp = dpdjk if max_dp < dpdjk
    end
  end

  puts max_dp
end