SP2038 TILING - Rectangle Tiling
Description
We say that a 2-dimensional, rectangular word w of size n×m (imagine it as a board with letter written in the squares) can be tiled with a rectangular pattern p if there are such occurrences of p in w (but not necessarily all of them) that no two of them overlap and each symbol (square) of w is covered by one of them. Given such word w, find a rectangular pattern p of smallest size (area) which the word w can be tiled with.
Input Format
The first line of input contains a number t (1
Output Format
For each test case output the smallest possible area of a pattern p that can be used to tile the given board.