Kayak

Time limit1sMemory limit128 MB

Problem

Sanggeun is hosting a kayak race. The race is broadcast live worldwide, and a satellite is photographing the whole course. Sanggeun wants to build a program that computes the live rankings from the satellite image.

The satellite image is a grid of $R$ rows and $C$ columns. The first cell of every row is S (the start line) and the last cell is F (the finish line). Nine teams take part, numbered 1 through 9. A kayak always occupies three horizontally consecutive cells in one row, and those three cells are all marked with the team's number. Water is shown as ..

A team's rank is determined by the distance between the finish line F and the kayak cell nearest to it (the rightmost of the kayak's three cells in that row). The shorter this distance (the closer to the finish line), the better the rank. If two teams are at the same distance, they share the same rank.

Input

The first line contains two integers $R$ and $C$. ($10 \le R, C \le 50$)

Each of the next $R$ lines is a row of the satellite map made of ., S, F, and the digits 1 through 9. Each row contains at most one kayak, and the image always contains exactly nine kayaks (one each for teams 1 through 9).

Output

Print nine lines. The $i$-th line contains the rank of team $i$ ($i = 1, 2, \dots, 9$).

Ranks start at 1. Teams with the same distance to the finish line share the same rank, and each next distinct distance increases the rank by exactly one (ranks are not skipped).