CF1301E Nanosoft

Description

Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building. The logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top left square is colored with red, the top right square is colored with green, the bottom left square is colored with yellow and the bottom right square is colored with blue. An Example of some correct logos: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1301E/b18bda37e952600d50a433d5d6d034271a8ea951.png) An Example of some incorrect logos: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1301E/aae70af4076310da7ad4524bd1dc8d30ba1f870a.png) Warawreh went to Adhami's store in order to buy the needed picture. Although Adhami's store is very large he has only one picture that can be described as a grid of $ n $ rows and $ m $ columns. The color of every cell in the picture will be green (the symbol 'G'), red (the symbol 'R'), yellow (the symbol 'Y') or blue (the symbol 'B'). Adhami gave Warawreh $ q $ options, in every option he gave him a sub-rectangle from that picture and told him that he can cut that sub-rectangle for him. To choose the best option, Warawreh needs to know for every option the maximum area of sub-square inside the given sub-rectangle that can be a Nanosoft logo. If there are no such sub-squares, the answer is $ 0 $ . Warawreh couldn't find the best option himself so he asked you for help, can you help him?

Input Format

N/A

Output Format

N/A

Explanation/Hint

Picture for the first test: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1301E/5c5a8909793534c432ad07cd7594615ef6950dde.png) The pictures from the left to the right corresponds to the options. The border of the sub-rectangle in the option is marked with black, the border of the sub-square with the maximal possible size, that can be cut is marked with gray.