Hide

Problem H
Scream Cipher

Languages en is
/problems/oskurdulmal/file/statement/en/img-0001.png
Image by Randall Munroe, xkcd.com

You are helping plan a birthday party for a coworker of yours but have to make sure they do not find out. Of course all discussions take place in a group chat only the relevant people have access to, but in a work place like this there is always a risk someone reads something off of a coworker’s screen, even just by accident. Thus a suggestion came up to use some kind of simple encryption that would just be enough to stop these kinds of sideways glances.

Some time later someone was spending time at work reading XKCD rather than programming and they suggested using the Scream Cipher.

It now falls to you to prepare a program that can encode and decode Scream Cipher text. Attached to the problem is a file giving all the usual letters in the first column and all the encoded letters in the second column.

Input

The first line contains a single letter that is either D or E. If it is D you should encode the following line and otherwise you should decode the following line. Next there is a line with up to $1000$ characters, along with a newline character. If it should be encoded the characters are all from the left column, otherwise they are all from the right column. In both cases spaces are allowed. The line will not start with a space nor end with a space (not counting the newline character). There will never be two spaces in a row.

Note that because the input is in UTF-8 format it may be the case that your programming language will not count characters in the way you might expect. Some of the symbols in the given table count as two characters in most programming languages.

Output

Print the encoded or decoded line. Spaces should be left unchanged.

Sample Input 1 Sample Output 1
D
A̰ÁĂĂÅ A̰Ả
HELLO HI
Sample Input 2 Sample Output 2
E
VEISLAN VERDUR FIMMTA JUNI
ÀÁẢÃĂAÂ ÀÁȂA̱ÄȂ A̮ẢǍǍĀA A̓ÄÂẢ

Please log in to submit a solution to this problem

Log in