MARK AND HIS GARDEN

0

0 votes
Medium
Problem

Mark has a flower garden of rectangular shape. The garden is divided into l rows and b columns to plant the flower trees. So total there are l*b parts in the garden .Only one tree can be planted in each part. In each part definitely tree is planted. In some part special trees are planted.The special tree in the part is represented by 'F' and remaining trees are represented by ".". Now robin has decided to buy the garden which is exactly of rectangular in shape but he cannot afford for whole and he wants only 'K' special plants in it. So help Robin to buy minimum rectangular area which contains exactly 'K' special plants.For better understanding refer sample input and output.

Input:

First line of input contains no of test cases denoted by T.

Each test case consists of length L breadth B and total special plants required K followed by configuration of garden with "."s and F's.

Output :

For each test case output minimum rectangular that contains exactly 'K' special plants. If no minimum area is possible then print '-1'.

Constraints:

1<=T<=100.

1<=L<=70.

1<=B<=70.

0<=k<=4900.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In testcase1 minimum area is obtained by choosing rectangle whose top left coordinate is (2,2) and bottom right coordinate as (3,4) which has two rows and 3 columns so minimum area obtained is 6.

In case testcase2 there is no rectange possible with k=3 . So answer is -1.

Editor Image

?