Hide

Problem H
Hnappasetningaskipti

A while back Arnar, Bjarki and Unnar competed together in competitive programming. At the university level, contestants also compete in three person teams, but each team only gets one computer. Therefore it is very important to use the time at the computer well, while the other two contestants try to solve other problems, and prepare to program their solutions quickly and correctly when it is their turn.

To make the most of his time, Bjarki decided to learn the dvorak keyboard layout, because he believes it allows him to type faster. Arnar thought this was a good idea and thus made his own keyboard layout which he called bjarki and moved onto using it. Unnar has decided to just stick to qwerty however, he does not think this is worth the effort. But this is now causing problems! When the three swap turns being at the computer, they sometimes start typing a whole bunch of things without realising the computer has the wrong keyboard layout active! Thus, they need a program that can take what has already been written and change it to what they intended to write.

A table follows that shows which keys correspond to one another in different keyboard layouts. Spaces are the same in all keyboard layouts. The table can also be found in the TSV format in the attachments.

qwerty

dvorak

bjarki

~

~

0

1

1

2

2

2

4

3

3

8

4

4

6

5

5

1

6

6

3

7

7

5

8

8

7

9

9

9

0

0

=

-

[

-

=

]

/

q

'

b

w

,

j

e

.

a

r

p

r

t

y

k

y

f

i

u

g

g

i

c

u

o

r

s

p

l

t

qwerty

dvorak

bjarki

[

/

.

]

=

,

a

a

l

s

o

o

d

e

e

f

u

m

g

i

p

h

d

d

j

h

c

k

t

n

l

n

v

;

s

q

'

-

;

z

;

[

x

q

]

c

j

y

v

k

z

b

x

h

n

b

w

m

m

f

,

w

x

.

v

'

/

z

~

Input

The first line is of the form type1 on type2 where type1 and type2 are qwerty, dvorak or bjarki. type2 is the keyboard layout currently active and type1 is the layout that the person at the computer is used to. Next there is a single line, the text that the person at the computer wrote. This text is always a single line but can contain all of the characters in the table above. This line will contain at most $1\, 000$ letters and at least one letter that is not whitespace.

Output

Print what the person at the computer intended to write. The output will be considered correct even if the whitespace is not an exact match, as long as the words match. For example a single space and two consecutive spaces will be considered equivalent.

Scoring

Group

Points

Constraints

1

1

The input is the sample input.

2

11

The input starts with qwerty on qwerty.

3

11

The input starts with dvorak on dvorak.

4

11

The input starts with bjarki on bjarki.

5

11

The input starts with dvorak on qwerty.

6

11

The input starts with bjarki on qwerty.

7

11

The input starts with qwerty on dvorak.

8

11

The input starts with bjarki on dvorak.

9

11

The input starts with qwerty on bjarki.

10

11

The input starts with dvorak on bjarki.

Sample Input 1 Sample Output 1
qwerty on qwerty
thetta helst obreytt
thetta helst obreytt
Sample Input 2 Sample Output 2
dvorak on qwerty
o.yqtxmal ekrpat
setxkbmap dvorak
Sample Input 3 Sample Output 3
bjarki on dvorak
c'ls qnpttp eg l wylszp
hvar stilli eg a bjarki

Please log in to submit a solution to this problem

Log in