// (C) Timofey S. Chistyakov 2005

{$apptype console}

uses
  Math, Types;

type
  TColRowDesc = array of array of TWordDynArray;

var
  n: integer;
  m: array of TByteDynArray;
  cols, rows: TColRowDesc;

procedure FillDesc(var ADesc: TColRowDesc; AIsCol: boolean);
var
  i, j, k, cnt: integer;
begin
  SetLength(ADesc, n, n, n);
  for i := 0 to n - 1 do
    for j := 0 to n - 1 do begin
      cnt := 0;
      if AIsCol then begin
        for k := n - 1 downto 0 do begin
          if (m[i, k] = m[j, k]) then
            Inc(cnt)
          else
            cnt := 0;
          ADesc[i, j, k] := cnt;
        end;
      end
      else begin
        for k := n - 1 downto 0 do begin
          if (m[k, i] = m[k, j]) then
            Inc(cnt)
          else
            cnt := 0;
          ADesc[i, j, k] := cnt;
        end;
      end;
    end;
end;

var
  fi, fo: textfile;
  i, j, k: integer;
  bestTile, tile, bestI, bestJ: integer;
  t: integer;
begin
  Read(n);
  //Assert(InRange(n, 1, 370));

  SetLength(m, n, n);
  for i := 0 to n - 1 do
    for j := 0 to n - 1 do begin
      Read(t);
//      Assert(InRange(1, 0, 255));
      m[i, j] := t;
    end;

//  Assert(SeekEof(fi));

  FillDesc(cols, true);
  FillDesc(rows, false);

  bestTile := 0;
  bestI := -1;
  bestJ := -1;
  for i := 0 to n - 1 do
    for j := 0 to n - 1 do
      for k := Min(n - i, n - j) downto bestTile + 1 do begin  // size
        if
          (cols[i, i + k - 1, j] >= k) and (rows[j, j + k - 1, i] >= k)
        then begin
          tile :=
            MinIntValue([k, cols[i, i + k - 1, j], rows[j, j + k - 1, i]]);
          if tile > bestTile then begin
            bestTile := tile;
            bestI := i;
            bestJ := j;
            Break;
          end;
        end;
      end;
  Write(bestI + 1, ' ', bestJ + 1, ' ', bestTile);

end.
