eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Mirror, Mirror on the Wall

Mirror, Mirror on the Wall

Во многих шрифтах, строчные буквы b и d являются зеркальными отображениями друг друга, так же как и буквы p и q. Буквы i, o, v, w и x являются зеркальным отображением самих себя. Хотя существуют и другие симметрии в шрифтах, в этой задаче мы будем рассматривать только те, которые выше упомянуты.

Because of these symmetries, it is possible to encode certain words based upon how those words would appear in the mirror. For example the word "boxwood" would appear as "boowxod", and the word "ibid" as "bidi". Given a particular sequence of letters, you are to determine its mirror image or to note that it is invalid.

Входные данные

Contains a series of letter sequences, one per line, followed by a single line with # character. Each letter sequence consists entirely of lowercase letters.

Выходные данные

For each letter sequence, if its mirror image is a legitimate letter sequence based upon the given symmetries, then output that mirror image. If the mirror image does not form a legitimate sequence of characters, then output the word INVALID.

Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
boowxod
bidi
bed
bbb
#
Выходные данные #1
boxwood
ibid
INVALID
ddd