시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 10 8 7 77.778%

문제

You have just bought land and want to plant the largest rectangular field possible. In surveying your land, you find a number of obstacles and decide to draw a map. You indicate in each square of the map whether it contains grass (G), rock (R), water (W), shrubs (S), or trees (T). While the grass can be mowed and the shrubs dug from the ground, the water, rocks, and trees cannot be removed. Given these obstacles, determine the area of the largest rectangular field.

입력

The first line of input gives the number of cases, N.
N test cases follow. For each test case there will be:

  • One line containing two space-separated integers indicating the length (L) and width (W) of your land.
  • Followed by, W lines, each containing L characters where each indicates the conditions for that square of land (one of G, R, W, S, or T).

Limits

  • 1 ≤ L ≤ 50
  • 1 ≤ W ≤ 50
  • N ≤ 10
  • Fewer than 5 obstacles in each test case.

출력

For each test case, output one line containing "Case #x: " followed by the maximum area of the largest rectangle that can be cleared.

예제 입력 1

4
1 1
G
2 2
GS
SG
2 2
GT
GG
5 8
GGTGG
TGGGG
GSSGT
GGGGT
GWGGG
RGTRT
RTGWT
WTWGR

예제 출력 1

Case #1: 1
Case #2: 4
Case #3: 2
Case #4: 9

채점

  • 예제는 채점하지 않는다.