Flag Bearer
시간 제한1초메모리 제한1024 MB
각 9x9 세마포 신호를 글자로 해독하고 알파벳에서 C만큼 이동한 뒤 같은 그림 형식으로 암호문을 출력한다.
문제
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 . Each letter in the message is encrypted by replacing it with the letter that is 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 , 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 () and (), representing the length of the word to be encrypted and the constant of the Caesar cipher. Next, there are lines, each with characters. Each successive lines represent one character in the message. The characters are “.”, “*”, or “#”. Asterisk “*” appears only once in each lines and it corresponds to the center of the semaphore scheme. Hash symbols “#” correspond to limbs. Coded words use standard English alphabet with characters.
출력
Print the encrypted message, in the same format as the input.