Scientists from the planet Krypton have figured out a way to grow artificial sugar in space. They have constructed a huge 3-dimensional steel grid upon which they will produce artificial sugar. Each sugar stock will be attached to a point on the grid. A cosmic ant wants to crawl from stock X to stock Y along the grid line.

âThe cosmic ant always chooses the shortest possible path along the grid lines while going from stock X to stock Y. The ant has an Energy capacity, and he loses 1 unit energy in walking 1 unit of distance.â

Here shortest path on grid line means manhattan distance.

âThen they will ask you to find out the minimum required energy capacity for the ant such that the ant can visit any sugar stock from any other sugar stock.â

And here minimum required energy capacity for visiting any point to any other point on grid means that minimum manhattan distance between farthest two points available on the grid. So you have to calculate the maximum of minimum distance between all possible pair of points on the grid.

Lastly all test cases are correct and You can have a look on the editorial for the solution idea.

Sorry i misunderstood the question. I thought it was asking for maximum manhattan distance from a single point to other points not from any point to any other point. Please forgive my silliness.