import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int C, D, W, X;
    int[][] E;
    int[][] F;

    bool input() {
        scanf("%d %d %d %d\n", &C, &D, &W, &X);
        if (C == 0 && D == 0 && W == 0 && X == 0) return false;
        E = new int[][C];
        F = new int[][C];
        foreach (i; 0 .. C) {
            E[i] = readln.chomp.split(" ").map!(to!int).array;
        }
        foreach (i; 0 .. C) {
            F[i] = readln.chomp.split(" ").map!(to!int).array;
        }
        return true;
    }

    auto memo = new int[][][](31, 51, 6);
    auto memo2 = new int[][][][][](15, 31, 51, 6, 2);
    void solve() {
        foreach (i; 0 .. D + 1) foreach (j; 0 .. W + 1) memo[i][j][] = -1;
        foreach (i; 0 .. C) foreach (j; 0 .. D + 1) foreach (k; 0 .. W + 1) foreach (l; 0 .. X + 1) memo2[i][j][k][l][] = -1;
        int dfs(int d, int w, int x) {
            int dfs2(int c, int d, int w, int x, int dir) {
                if (memo2[c][d][w][x][dir] >= 0) return memo2[c][d][w][x][dir];
                //writeln("dfs2: ", [c, d, w, x, dir]);
                int Ret = dfs(d + 1, w, x);
                int i = (dir == 0 ? -1 : 1);
                if (! (c + i < 0 || c + i >= C || E[c + i][d] == 0 || w - F[c + i][d] < 0)) {
                    Ret = max(Ret, dfs2(c + i, d, w - F[c + i][d], x, dir) + E[c + i][d]);
                }
                return memo2[c][d][w][x][dir] = Ret;
            }
            if (d == D) return 0;
            if (memo[d][w][x] >= 0) return memo[d][w][x];
            int Ret = dfs(d + 1, w, x);
            foreach (c; 0 .. C) {
                if (E[c][d] == 0) continue;
                if (w - F[c][d] < 0) continue;
                Ret = max(Ret, dfs(d + 1, w - F[c][d], x) + E[c][d]);
                if (x >= 1) {
                    for (int i = -1; i <= 1; i += 2) {
                        if (c + i < 0 || c + i >= C) continue;
                        if (E[c + i][d] == 0) continue;
                        if (w - F[c][d] - F[c + i][d] < 0) continue;
                        Ret = max(Ret, dfs2(c + i, d, w - F[c][d] - F[c + i][d], x - 1, i > 0) + E[c][d] + E[c + i][d]);
                    }
                }
            }
            return memo[d][w][x] = Ret;
        }
        writeln(dfs(0, W, X));
    }
    
    while (input) solve;
}