A Harder Contest '19 - Spy

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem types

You are a spy sent to DMOJstan to sabotage their internal servers. To keep communications with your nation (WLMOJstan) private, you are issued a one-time pad code book.

The code book and encrypted messages are both strings of numeric digits.

You want to create program to help you decode communications so you can spend more time on espionage.

One-time pad decryption works as follows:

  1. Split each string into two-digit blocks: each two-digit block in the encrypted message corresponds with a two-digit block at the same position in the code book.
  2. Subtract the first block in the encrypted message by the first block in the code book.
  3. Find the character at position X (1 \leq X \leq 26) of the alphabet, where X is the result of the operation performed in the previous step.
  4. Repeat steps 2 and 3, moving to the next block each time until all blocks have been decrypted.

For example, if the encrypted message is 43125223 and the code book is 42104919, the blocks for the encrypted message would be 43 12 52 23 and the blocks for the code book would be 42 10 49 19.

43 - 42 = 1, therefore the first letter is A.
12 - 10 = 2, therefore the second letter is B.
52 - 49 = 3, therefore the third letter is C.
23 - 19 = 4, therefore the fourth letter is D.

The message therefore would be ABCD

Input Specification

The input consists of 2 lines.

The first line will be the code book, C (1 \leq |C| \leq 2000), the length of which is even.

The second line will be the encrypted message, E (|E| = |C|)

It is guaranteed that the decrypted message will be a string consisting of alphabet letters.

Output Specification

The output will consist of one line of uppercase letters, the decrypted message.

Sample Input


Sample Output



There are no comments at the moment.