Game with Balls
In a popular game often played on handheld devices, the action unfolds on an 11 by 11 square grid, divided into 121 smaller squares.
At the start, each square contains a ball of one of five colors: red (R), blue (B), green (G), yellow (Y), or purple (V). A connected region for a given ball includes all balls that can be reached from it by moving one square at a time, either vertically or horizontally, without crossing the grid's boundaries and only passing through balls of the same color.
When a ball is selected, all balls in its connected region are automatically selected as well. If this region contains at least 2 balls, they disappear, and the player earns n·(n-1) points, where n is the number of balls in the connected region.
Given the initial arrangement of the balls, you need to determine the maximum points that can be scored on the first move by selecting a ball of each color.
Input
The input consists of 11 lines, each containing 11 characters, representing the playing field.
Output
For each ball color, output the maximum number of points that can be scored by selecting a ball of that color, following the format shown in the example.