#975
Unrated
KAJAK
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Mirko and Slavko are sports commentators on a local kayaking competition. They have a live satellite feed of the entire track. Since there are too much teams for our dynamic duo to follow, they asked you to help them. They would like you to write a program that will display current standings team- by-team. The satellite feed is encoded as a table of R rows C characters each. The first character in each row is the starting line, encoded by the character 'S'. The last character in each row is the finishing line, encoded by 'F'. There are exactly nine kayaks on the image. Each kayak is marked by his number, and each spans exactly three consecutive columns. Water is marked by '.'. Teams are ranked by their distance to the finish line. Smaller is better. If two teams are at the same distance, they share their place.

입력

The first line of input contains two integers R and C (10 ≤R, C ≤50), the number of rows and columns of the encoded satellite image. Each of the following R lines contains exactly S characters '.', 'S', 'F' and 'digits 1' to '9'. Each row will contain at most one kayak. Each image contains all 9 kayaks.

출력

Output nine lines, one for each kayak. The ith line should contain the current rank of the ith team.

예제 입력 1

10 10
S.....111F
S....222.F
S...333..F
S..444...F
S.555....F
S666.....F
S.777....F
S..888...F
S...999..F
S........F

예제 출력 1

1
2
3
4
5
6
5
4
3

예제 입력 2

10 15
S..........222F
S.....111.....F
S...333.......F
S...555.......F
S.......444...F
S.............F
S......777....F
S..888........F
S........999..F
S...666.......F

예제 출력 2

5
1
6
3
6
6
4
7
2
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.