The Chibi Battle is perhaps the most famous battle in the history of China. Liu Bei and Sun Quan won the battle after using a series of wonderful stratagem. Now, they are going to catch the leader of their enemy Cao Cao.
In order to help Cao Cao to escape, the soldiers of Cao Cao have been divided into several parts, and Cao Cao is in one of these part. Now they are all in a rectangle area which can be divided into many squares of the equal size. Once the soldiers get out of this area, they escape successfully.
Because Liu Bei and Sun Quan don't know exactly which part Cao Cao is in, so they all Cao Cao's soldiers.
In this area, some squares are lawns that can be passed, while some squares are Marshes that can't be passed. Liu Bei and SunQuan decide to set fire on lawns to those squares can't be passed. Because some reasons, set fire on different squares needs different length of time. And they can only set fire on one square at the same time. Now, Cao Cao and all his soldiers are having rest and you can assume that they won't move. Liu Bei and SunQuan want to know how much time they need at least to set fire to make Cao Cao and all his soldiers can't escape any way when they want to move. Can you help them?