<?xml version="1.0" encoding="Windows-1251"?>
<CATS version="1.0">
<Problem title="Harder Sokoban Problem" lang="en" author="A. Klenin" tlimit="5" mlimit="16"
    inputFile="input.txt" outputFile="output.txt" stdChecker="nums">

<ProblemStatement>
<p>The game of sokoban is played in a rectangular labirinth of <i>N</i> by <i>N</i> cells
  with each cell either empty, denoted by '<tt>.</tt>' character (ASCII 46),
  or occupied by wall, denoted by '<tt>#</tt>' character (ASCII 35).
  There is also a single destination cell, denoted by '<tt>*</tt>' character (ASCII 42).
</p>
<p>One player and one container are located in the empty cells of the labirinth.
The player can move between the empty cells in horizontal or vertical direction.
If the cell where the player tries to move is occupied by container, the container is "pushed"
to the next cell in the same direction. That next cell must, of course, be empty.
</p>
<p>The objective of the game is well-known:
to place the container in the destination cell with the minimum number of moves. Your task, however, is different: 
given the field, select starting position for the player and the container
so as to maximize the required number of moves.
</p>
</ProblemStatement>

<InputFormat>
First line of input contains number <i>N</i> -- the field size.
The following <i>N</i> lines consist of <i>N</i> characters each -- representation the field.
The input field always contains at least one empty cell adjacent to the destination cell.
</InputFormat>

<OutputFormat>
Output file must contain a single integer -- the maximal number of moves.
</OutputFormat>

<ProblemConstraints>
2 &amp;le; <i>N</i> &amp;le; 25
</ProblemConstraints>

<Sample rank="1">
  <SampleIn>2
..
.*</SampleIn>
  <SampleOut>0</SampleOut>
</Sample>
<Sample rank="2">
  <SampleIn>3
..#
...
..*</SampleIn>
  <SampleOut>10</SampleOut>
</Sample>

<Solution name="sol" src="hardsoko.dpr"/>
<TestRange from="1" to="11"><In src="t%0n"/><Out use="sol"/></TestRange>
<Generator name="g1" src="g1.dpr"/>
<Test rank="12"><In use="g1" param="10 15"/><Out use="sol"/></Test>
<Test rank="13"><In use="g1" param="14 20"/><Out use="sol"/></Test>
<Test rank="14"><In use="g1" param="25 20"/><Out use="sol"/></Test>

</Problem>
</CATS>