- Time limit: 1.00 s
- Memory limit: 512 MB
You are given a grid of letters. Your task is to calculate, for each letter, the number of rectangular subgrids whose border consists of that letter.
Input
The first line has two integers and : the size of the grid and the number of letters. The letters are the first uppercase letters.
After this, there are lines that describe the grid. Each line has letters.
Output
Print lines: for each letter, the number of subgrids.
Constraints
Example
Input:
5 3 ABBBC ABABC ABBBC ABBBC CCCCC
Output:
11 38 29