시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 442 172 166 46.369%

문제

상근이는 카약 대회를 개최했다. 대회는 전세계에 생중계되고, 위성이 경기장 전체를 촬영하고 있다. 상근이는 위성 사진을 바탕을 실시간 순위를 계산하는 프로그램을 만드려고 한다.

위성 사진은 R행 C열이다. 모든 줄의 첫번째 글자는 'S'이고 출발선을 의미한다. 또, 마지막 글자는 'F'이고 이것은 결승선을 의미한다. 대회에 참가한 팀은 총 9팀이고, 각 팀은 1부터 9까지 번호가 매겨져 있다. 카약은 항상 열에 대해 연속하는 세 칸을 차지하며, 카약 번호로 표시한다. 마지막으로 물은 '.'로 나타나 있다.

팀의 순위는 결승선으로부터 떨어진 거리로 측정한다. 가까울수록 순위가 높다. 만약, 두 팀이 결승선과 떨어진 거리가 같다면, 같은 등수이다.

입력

첫째 줄에 R과 C가 주어진다. 다음 R개 줄에는 '.', 'S', 'F', '1'~'9'로 이루어진 위성 지도가 주어진다. 한 줄에는 최대 한 개의 카약만 있고, 위성 사진에 있는 카약은 항상 9개이다. (10 ≤ R, C ≤ 50)

출력

출력은 총 9줄을 해야 한다. i번째 줄에는 i번 팀의 등수를 출력한다. (i=1~9)

예제 입력 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
W3sicHJvYmxlbV9pZCI6IjI4OTAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWNlNzRcdWM1N2QiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzBjMVx1YWRmY1x1Yzc3NFx1YjI5NCBcdWNlNzRcdWM1N2QgXHViMzAwXHVkNjhjXHViOTdjIFx1YWMxY1x1Y2Q1Y1x1ZDU4OFx1YjJlNC4gXHViMzAwXHVkNjhjXHViMjk0IFx1YzgwNFx1YzEzOFx1YWNjNFx1YzVkMCBcdWMwZGRcdWM5MTFcdWFjYzRcdWI0M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

  • 문제의 오타를 찾은 사람: adh0463
  • 문제를 번역한 사람: baekjoon
  • 빠진 조건을 찾은 사람: hihihi