{ Vanja Petrovic Tankovic i Nenad Bozidarevic - RAF, Beograd }

var Dolina           : array [0..51,0..51]   of LongInt;
    Dostupno         : array [0..2501]       of LongInt;
    Memo             : array [0..2501]       of LongInt;
    maxVrednost, minPolja, dlx, dly, gdx, gdy : LongInt;
    n, m, i, j, h, w, l                       : LongInt;
    pare, maxPolja, vrednost, iteracija       : LongInt;

Begin
  Readln(n, m);

  for i := n downto 1 do
  Begin
    for j := 1 to m do Read(Dolina[i,j]);
    Readln;
  end;
  Readln(pare);

  maxPolja := pare div 1000000;
  minPolja := 2501;

  for i := 1 to n do
    for j := 1 to m do
      if Dolina[i,j] > 0
        then inc(Dostupno[Dolina[i,j]]);

  for i := n downto 1 do
    for j := m downto 1 do
    Begin
      w := 0;
      while (j + w <= m) and (w+1 <= maxPolja) do
      Begin
        vrednost  := 0;
        h         := 0;
        Inc(iteracija);
        While (i + h <= n) and ((h+1)*(w+1) <= maxPolja) do
        Begin
	  for l := 0 to w do
            if Memo[Dolina[i+h, j+l]] <> iteracija
              then Begin
                     Memo[Dolina[i+h, j+l]] := iteracija;
                     vrednost := vrednost + Dostupno[Dolina[i+h, j+l]];
                   end;
          if (vrednost > maxVrednost) or
             (vrednost = maxVrednost) and ((h+1)*(w+1) < minPolja)
            then Begin
                   minPolja   := (h+1)*(w+1);
                   maxVrednost:= vrednost;
                   dlx        := j;
                   dly        := i;
                   gdx        := j+w;
                   gdy        := i+h;
		 end;
          inc(h);
        end;
        inc(w);
      end;
    end;
  Writeln(dlx, ' ', dly, ' ', gdx, ' ',gdy);
  Writeln(pare - minPolja * 1000000);
  Writeln(maxVrednost);
end.
