Building a House (Small)

Find the area of the largest axis-aligned rectangle containing only grass and shrub cells on each grid map.

Medium5StackMatrixInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

You just bought a piece of land and want to plant the largest rectangular field you can. Surveying the land turns up several obstacles, so you draw a map. Each square of the map records what is on it: grass (G), rock (R), water (W), shrubs (S), or trees (T). You can mow the grass and dig out the shrubs, but water, rocks, and trees cannot be removed.

Given the map, find the area of the largest rectangle made only of squares you can clear. The sides of the rectangle must run along the grid lines.

Input

The first line contains the number of test cases, N. N test cases follow. Each test case has this form:

  • One line with two space separated integers, the length L and the width W of your land.
  • Then W lines, each with L characters. Each character gives the state of that square and is one of G, R, W, S, T.

Limits

  • 1L501 \le L \le 50
  • 1W501 \le W \le 50
  • 1N101 \le N \le 10

Output

For each test case, print one line with Case #x: followed by the area of the largest rectangle that can be cleared. Here xx is the test case number, counting from 1. Print 0 when no square can be cleared.