Flag Bearer

시간 제한1초메모리 제한1024 MB

요약
각 9x9 세마포 신호를 글자로 해독하고 알파벳에서 C만큼 이동한 뒤 같은 그림 형식으로 암호문을 출력한다.
난이도

쉬움10점 중 3점

유형
구현, 문자열, 시뮬레이션
정답자
아직 제출이 없습니다

문제

The bears have decided to abandon their solitary lives as predators and hunt together. They have formed two groups on the opposite sides of the farm and are preparing to abduct several smaller piglets, whose fate now seems very uncertain.

To prevent their plans from being revealed, the bears will communicate during the operation at a distance using the semaphore alphabet, which they will further encrypt with Caesar’s cipher. Caesar’s cipher is defined by a single non-negative integer CC. Each letter in the message is encrypted by replacing it with the letter that is CC positions further in the alphabet. When the position of the used letter goes beyond the end of the alphabet, counting continues cyclically from the start of the alphabet. So, for example, with C=5C = 5, the second-to-last letter in the alphabet is encrypted as the fourth letter in the alphabet. Each letter of the semaphore alphabet is encoded by the position of two lower or upper limbs of a signaling mammal that stands upright, facing the recipient of the message. In the diagram shown below, the center of the diagram represents the torso position of the signaling mammal, and its two limbs are represented by two of the eight possible segments radiating from the center. The assignment between limb positions and letters of the alphabet is provided on a separate page (following the samples).

Now, the bears are going to encrypt their short messages. They are good at semaphore alphabet, but they need some help with Caesar’s cipher. Please provide them with this assistance.

입력

The first input line contains two integers NN (1≤N≤261 ≤ N ≤ 26) and CC (0≤C≤250 ≤ C ≤ 25), representing the length of the word to be encrypted and the constant of the Caesar cipher. Next, there are 9N9N lines, each with 99 characters. Each 99 successive lines represent one character in the message. The characters are “.”, “*”, or “#”. Asterisk “*” appears only once in each 99 lines and it corresponds to the center of the semaphore scheme. Hash symbols “#” correspond to limbs. Coded words use standard English alphabet with 2626 characters.

출력

Print the encrypted message, in the same format as the input.

예제2

  1. 예제 1

    입력
    5 9
    .........
    .........
    .........
    .........
    .###*....
    .....#...
    ......#..
    .......#.
    .........
    .........
    .......#.
    ......#..
    .....#...
    ....*....
    ...#.....
    ..#......
    .#.......
    .........
    .........
    .......#.
    ......#..
    .....#...
    ....*....
    ....#....
    ....#....
    ....#....
    .........
    .........
    .......#.
    ......#..
    .....#...
    ....*....
    ....#....
    ....#....
    ....#....
    .........
    .........
    ....#....
    ....#....
    ....#....
    .###*....
    .........
    .........
    .........
    .........
    
    예상 출력
    .........
    .........
    .........
    .........
    .###*....
    ....#....
    ....#....
    ....#....
    .........
    .........
    .#.....#.
    ..#...#..
    ...#.#...
    ....*....
    .........
    .........
    .........
    .........
    .........
    .........
    .........
    .........
    ....*....
    ...#.#...
    ..#...#..
    .#.....#.
    .........
    .........
    .........
    .........
    .........
    ....*....
    ...#.#...
    ..#...#..
    .#.....#.
    .........
    .........
    .#.......
    ..#......
    ...#.....
    ....*###.
    .........
    .........
    .........
    .........
    
  2. 예제 2

    입력
    5 17
    .........
    .........
    .........
    .........
    ....*....
    ...##....
    ..#.#....
    .#..#....
    .........
    .........
    .........
    .........
    .........
    .###*###.
    .........
    .........
    .........
    .........
    .........
    .......#.
    ......#..
    .....#...
    ....*....
    ....#....
    ....#....
    ....#....
    .........
    .........
    .........
    .........
    .........
    ....*....
    ...#.#...
    ..#...#..
    .#.....#.
    .........
    .........
    .........
    .........
    .........
    ....*....
    ...##....
    ..#.#....
    .#..#....
    .........
    
    예상 출력
    .........
    .........
    .........
    .........
    .###*###.
    .........
    .........
    .........
    .........
    .........
    .#.......
    ..#......
    ...#.....
    ....*....
    ...#.....
    ..#......
    .#.......
    .........
    .........
    ....#....
    ....#....
    ....#....
    ....*....
    .....#...
    ......#..
    .......#.
    .........
    .........
    .......#.
    ......#..
    .....#...
    ....*....
    ....#....
    ....#....
    ....#....
    .........
    .........
    .........
    .........
    .........
    .###*###.
    .........
    .........
    .........
    .........