import std.stdio;
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 W, H;
    int F, M, O;
    int[][] G;
    bool input() {
        scanf("%d %d", &W, &H);
        if (W == 0 && H == 0) return false;
        scanf("%d %d %d", &F, &M, &O);
        G = new int[][](H, W);
        foreach (i; 0 .. H) {
            foreach (j; 0 .. W) {
                scanf("%d", &G[i][j]);
            }
        }
        return true;
    }

    const INF = int.max / 4;
    auto Cache = new int[][][][](10, 10, 1 << 10, 50 + 1);
    void solve() {
        foreach (i; 0 .. H) foreach (j; 0 .. W) foreach (k; 0 .. (1 << W)) foreach (l; 0 .. M + 1) Cache[i][j][k][l] = -1;
        int dfs(int y, int x, int used, int roxy) {
            if (roxy <= 0) return INF;
            if (y == H - 1) return 0;
            if (Cache[y][x][used][roxy] >= 0) return Cache[y][x][used][roxy];
            int Ret = INF;
            if (G[y + 1][x] >= 0) {
                Ret = min(Ret, dfs(y + 1, x, 1 << x, min(M, roxy - 1 + G[y + 1][x])));
            } else {
                Ret = min(Ret, dfs(y + 1, x, 1 << x, roxy - 1) - G[y + 1][x]);
            }
            if (0 <= x - 1 && x - 1 < W) {
                if (used & (1 << (x - 1))) {
                    Ret = min(Ret, dfs(y, x - 1, used, roxy - 1));
                } else {
                    if (G[y][x - 1] >= 0) {
                        Ret = min(Ret, dfs(y, x - 1, used | (1 << (x - 1)), min(M, roxy - 1 + G[y][x - 1])));
                    } else {
                        Ret = min(Ret, dfs(y, x - 1, used | (1 << (x - 1)), roxy - 1) - G[y][x - 1]);
                    }
                }
            }
            if (0 <= x + 1 && x + 1 < W) {
                if (used & (1 << (x + 1))) {
                    Ret = min(Ret, dfs(y, x + 1, used | (1 << (x + 1)), roxy - 1));
                } else {
                    if (G[y][x + 1] >= 0) {
                        Ret = min(Ret, dfs(y, x + 1, used | (1 << (x + 1)), min(M, roxy - 1 + G[y][x + 1])));
                    } else {
                        Ret = min(Ret, dfs(y, x + 1, used | (1 << (x + 1)), roxy - 1) - G[y][x + 1]);
                    }
                }
            }
            //[y, x, used, roxy].writeln;
            return Cache[y][x][used][roxy] = Ret;
        }

        int Ans = INF;
        foreach (int i; 0 .. W) {
            if (G[0][i] >= 0) {
                Ans = min(Ans, dfs(0, i, 1 << i, max(M, O - 1 + G[0][i])));
            } else {
                Ans = min(Ans, dfs(0, i, 1 << i, O - 1) - G[0][i]);
            }
        }
        writeln(Ans > F ? "NA" : Ans.to!string);
    }

    while (input) solve;
}