Problem J
Hail, Caesar!
Those pesky Romans are about to attack your village. Luckily your spies have managed to intercept letters from their general and you hope that one of them contains information about the timing of the attack. There is only one problem; they are encrypted!
The Romans use an encryption system which is based on shifting the letters of the alphabet. For example, the word ATTACK becomes CVVCEM when the letters are shifted by $2$, such as A -> C, T -> V, K -> M. In order to decrypt those messages, you just have to find out by how many letters you must shift each character.
As you look at the encrypted messages, you notice a pattern. The first line is always the same length. “Hmm, could this be a greeting of some sorts?”, you ask yourself.
Kdlo/#Fdhvdu$
Using an ASCII table and a pen and paper, you try different shifts until you finally crack it. The first line says:
Hail, Caesar!
This is brilliant! Now you can figure out which shift was used just by looking at the first character!
Since you have a large number of messages to decrypt, each of which may have been encrypted with a different shift, you decide to write a program to do so. But hurry, the fate of your village may depend on your programming skills.
Input
Input consists of exactly four lines, representing the encrypted message. It is guaranteed that each character in the input, except for the newline characters, belongs to the set of printable characters in the ASCII table, in other words, characters numbered from $32$ to $126$, inclusive. Each line contains at most $50$ printable characters.
Output
Output the decrypted message. It is guaranteed that each character in the output also belongs to the set of printable characters in the ASCII table. Take care to wrap numbers around should they be shifted outside of this range.
Sample Input 1 | Sample Output 1 |
---|---|
Mfnq1%Hfjxfw& Mt|%nx%ymj%|jfymjwD Ny,x%{jw~%mty%t{jw%mjwj3 ux3%Gwzyzx%ktwlty%mnx%xfsifqx3 |
Hail, Caesar! How is the weather? It's very hot over here. ps. Brutus forgot his sandals. |
Sample Input 2 | Sample Output 2 |
---|---|
Hail, Caesar! I forgot my encryption device, sorry! We are running low on supplies. Brutus eats a lot. |
Hail, Caesar! I forgot my encryption device, sorry! We are running low on supplies. Brutus eats a lot. |
Sample Input 3 | Sample Output 3 |
---|---|
G`hk+~B`dr`q Vd~`ss`bj~`s~c`vm Sgd~dmdlx~g`r~addm~o`qsxhmf~`kk~mhfgs Aqtstr~hr~`mmnxdc~sg`s~gd~b`m&s~inhm~hm |
Hail, Caesar! We attack at dawn The enemy has been partying all night Brutus is annoyed that he can't join in |
Sample Input 4 | Sample Output 4 |
---|---|
Jckn."Ecguct# Dg"tgcf{"hqt"cvvcem Fqp)v"ngv"vjg"gpgo{"ugg"{qw Ocmg"uwtg"Dtwvwu"uvc{u"swkgv |
Hail, Caesar! Be ready for attack Don't let the enemy see you Make sure Brutus stays quiet |