The following languages are only available languages for the problems from the contest

Kotlin Heroes: Episode 7:

- Kotlin 1.4.31

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
H. Submatrices

time limit per test

3.5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given matrix $$$s$$$ that contains $$$n$$$ rows and $$$m$$$ columns. Each element of a matrix is one of the $$$5$$$ first Latin letters (in upper case).

For each $$$k$$$ ($$$1 \le k \le 5$$$) calculate the number of submatrices that contain exactly $$$k$$$ different letters. Recall that a submatrix of matrix $$$s$$$ is a matrix that can be obtained from $$$s$$$ after removing several (possibly zero) first rows, several (possibly zero) last rows, several (possibly zero) first columns, and several (possibly zero) last columns. If some submatrix can be obtained from $$$s$$$ in two or more ways, you have to count this submatrix the corresponding number of times.

Input

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 800$$$).

Then $$$n$$$ lines follow, each containing the string $$$s_i$$$ ($$$|s_i| = m$$$) — $$$i$$$-th row of the matrix.

Output

For each $$$k$$$ ($$$1 \le k \le 5$$$) print one integer — the number of submatrices that contain exactly $$$k$$$ different letters.

Examples

Input

2 3 ABB ABA

Output

9 9 0 0 0

Input

6 6 EDCECE EDDCEB ACCECC BAEEDC DDDDEC DDAEAD

Output

56 94 131 103 57

Input

3 10 AEAAEEEEEC CEEAAEEEEE CEEEEAACAA

Output

78 153 99 0 0

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/29/2022 07:57:33 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|