시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 32 MB 139 96 87 71.311%

문제

메뚜기 재석이는 간만에 목초지에서 신났당. 무지무지 신났당. 너무너무 신나서 뛰어놀다가 그만!! 핸드폰을 물웅덩이에 빠뜨리고 말았다. 그 덕에 핸드폰은 젖어버렸고, 자판은 요상하게 작동한다. 

메뚜기 재석이는 고장난 자판이 뭐가 눌리는 건지 알아야 문자라도 보낼테니 재석이는 이것저것 눌러보기 시작했다. 메뚜기인 것도 서러운데 핸드폰까지 고장났으니 누군가의 도움이 필요할 것 같다.

이 그림은 핸드폰의 자판이다(안타깝게도 재석이는 메뚜기라 스마트폰을 사지 못 했다.). 예를 들어, a를 입력하고 싶으면 2를 한 번 누르면 되고, b를 입력하고 싶으면 2를 두 번 누르면 된다. 만약 똑같은 키를 연속해서 눌러 다른 문자를 입력하고 싶으면 #을 누르면 된다. 예를 들어, klor을 입력하고 싶으면 55#555666777을 눌러 입력하면 된다. 

입력

첫째 줄엔 9개의 정수가 주어진다. 첫번째 정수는 원래 자판에서 1을 눌렀을 때 나오는 문자가 어느 자판을 눌렀을 때 나오는지, 두번째 정수는 원래 자판에서 2를 눌렀을 때 나오는 문자가 어느 자판을 눌러야 나오게 되었는지...이런 식이다. 

재석이는 *이랑 0은 쓸 수가 없다. #키는 망가지지 않았다.

두번째 줄엔 소문자로 된 문자열이 주어진다. 길이는 100 문자를 넘지 않는다.

출력

재석이의 메세지를 쓰기 위해 눌러야 하는 키를 출력한다.

예제 입력 1

2 3 4 5 6 7 8 9 1
klor

예제 출력 1

44#444555666

예제 입력 2

7 8 9 1 2 3 6 5 4
djevojka

예제 출력 2

68662227778#885

예제 입력 3

9 8 7 6 5 4 3 2 1
skakavac

예제 출력 3

33335585582228#888

힌트

Clarification of the first example: All of the keys are shifted one place to the right so the output differs a little bit from the example in the task statement.

W3sicHJvYmxlbV9pZCI6IjEwNTQ1IiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHViNjlj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