ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1715. Another Ball Killer

Time limit: 2.0 second
Memory limit: 64 MB
Contestants often wonder what jury members do during a contest. Someone thinks that they spend all the contest fixing bugs in tests. Others say that the jury members watch the contest excitedly and even bet on who will win. However, in reality, the jury members prefer to play computer games, giving a complete control of the contest to heartless machines.
Another Ball Killer is one of the favorite games of the jury. Its rules are very simple:
  1. The game is played by one person on a rectangular field of size n × m. At the initial moment, each cell of the field contains a ball of one of five colors: blue, green, red, white, or yellow.
  2. At each move, the player chooses some figure (a connected group of two or more balls of the same color; balls are called connected if their cells have a common side) and removes it from the field. After that the balls that were above the removed balls fall down. If a column without the balls appears, then all the columns on its right are shifted to the left.
    The image below shows how the field changes after the removal of the largest figure.
    The player is awarded k × (k − 1) points for his move, where k is the size of the removed figure, i.e. the number of balls in it.
  3. The game is finished when there are no figures left on the field. The goal is to get as many points as possible by the end of the game.
Problem illustration
Lazy jury members play Another Ball Killer using the following algorithm:
01  Choose the color of one of the balls in the field as the main color.
02  While there is at least one figure:
03      While there is at least one figure of a color different from the main color:
04          Remove the largest figure of a color different from the main color.
05      If there is a figure of the main color:
06          Remove the largest figure of the main color.
If there are several ways to remove the figure in lines 04 and 06, one should choose the largest figure containing the bottommost ball (if there are several such figures, then one should choose among them the figure that contains the leftmost of such balls).
Chairman is the laziest person in the jury. He doesn't even think about which color he should choose as the main one. By pressing one key, he launches a program that calculates for every color present in the field the number of points that will be awarded if this color is chosen as the main one. Your task is to write such a program.

Input

The first line contains the dimensions of the field n and m (1 ≤ n, m ≤ 50). Each of the following n lines contains m letters denoting the color of the ball in the corresponding cell of the field (B for blue, G for green, R for red, W for white, and Y for yellow). The rows of the playing field are given in the order from the top row to the bottom row.

Output

Output one line for each color present in the field: first output the letter denoting the color, then a colon, a space, and the number of points the chairman of the jury will get if he chooses this color as the main one. The colors must be considered in the following order: blue, green, red, white, yellow.

Sample

inputoutput
3 6
WWWGBG
WBGGGB
GGGGBB
B: 74
G: 92
W: 74
Problem Author: folklore (prepared by Eugene Krokhalev)
Problem Source: NEERC 2009, Eastern subregional contest