uses
    testlib, sysutils;
const
    maxn = 500;
type
    int = longint;
function bw(l, m, r: integer): boolean;
begin
    bw := (l <= m) and (m <= r);
end;
var
    n, m, i, j: integer;
    a: array[1 .. maxn,1 .. maxn] of int;
    pa, px1, py1, px2, py2: int;
    ja, pc: int;
begin
    n := inf.readlongint;
    m := inf.readlongint;

    pa := ouf.readlongint;
    px1 := ouf.readlongint;
    py1 := ouf.readlongint;
    px2 := ouf.readlongint;
    py2 := ouf.readlongint;

    if not bw(1, px1, px2 - 1) then
        quit(_wa, format('x1 (%d) is not between 1 and x2 (%d).', [px1, px2]));
    if px2 > n then
        quit(_wa, format('x2 (%d) > n (%d)', [px2, n]));
    if not bw(1, py1, py2 - 1) then
        quit(_wa, format('y1 (%d) is not between 1 and y2 (%d).', [py1, py2]));
    if py2 > m then
        quit(_wa, format('y2 (%d) > m (%d)', [py2, m]));

    pc := 0;
    for i := 1 to n do
        for j := 1 to m do begin
            a[i][j] := inf.readlongint;
            if (((i = px1) or (i = px2)) and bw(py1, j, py2))
            or (((j = py1) or (j = py2)) and bw(px1, i, px2)) then
                inc(pc, a[i][j]);
        end;


    if (pc <> pa) then
        quit(_wa, format('participant''s sum (%d) differs from declared (%d).', [pc, pa]));
    ja := ans.readlongint;
    if (pa > ja) then
        quit(_fail, format('participant''s sum (%d) is better than jury answer! (%d).', [pa, ja]));
    if (pa < ja) then
        quit(_wa, format('participant''s sum (%d) is worse than jury answer (%d).', [pa, ja]));

    quit(_ok, 'Ok. ' + inttostr(pa));
end.
