### 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)
        next if dp[i][j][k] < 0

        dp[i + 1][j][k] = [dp[i + 1][j][k], dp[i][j][k]].max

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

            next if k == x

            esum = es[r][i]
            j1 = j0

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

            esum = es[r][i]
            j1 = j0

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

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

  puts max_dp
end