KIT - Krypt in Time

no tags 

In a land far away people can travel back in time in person or send messages to them in the past. Sending messages that can change ones future is forbidden. The messages that are sent are intercepted by the time police. Jim wants to send a message to himself in the past to prevent his death. He decides to encrypt using a "number-pad". All the numbers in number-pad are between 0 and 25. The message he wants to send can be encrypted if each character in the string is encoded by a number from the pad provided each number from the number- pad is only used once. The encryption is done by shifting each letter in the message by k positions, where k is determined by the number-pad. Shift occurs between the alphabets "a" and "z". If a letter in the message is shifted past "z" then it starts back at "a" and continues to shift.

For example: If the number-pad contains 2, the message abc is transformed to cde and xyz to zab.

Input

The first line will contain the size of the number-pad N, followed by a sequence of numbers for the pad. The remaining input consists of a series of words to be encrypted using the number-pad. You may assume that the maximum size of the pad (N) is 100 numbers, all numbers in the pad are between 0 and 25, and that all input will be lowercase letters. The end of input is indicated by -1.

Output

For each word to be encrypted, output a line containing the encrypted word.

Example

Input:
10
1 2 3 4 5 4 3 2 1 0
aa aaa
zzzzz
-1

Output:
bc
def
dcbaz

hide comments
Simes: 2017-10-03 18:04:38

Poor description - it took me many WA to discover that the number pad can appear on multiple lines in the input.

Don't worry about what to do if the words to be encrypted contain more letters than the number pad does numbers - it's never tested for.

pt97: 2016-07-22 20:26:51

silly mistake causes me 3 WA :'( ..btw easy one

marcipanko: 2016-03-26 14:41:03

@godfrey_17897 You probably haven't considered that there could be more than N letters

godfrey_17897: 2016-01-11 20:55:28

any special test cases ?
code running perfectly on ideone

mrx: 2015-08-29 09:22:56

15007983, can you point out my mistake, I'm getting all cases correct.

:.Mohib.:: 2015-02-17 12:20:27

Just Love encryption... :)

Abhishek: 2014-12-24 16:43:11

AC in one Go ,
just move around the numberpad untill the input ends.

Baojun Wang: 2014-09-03 08:37:39

why limit language?

.:: Jarv1s ::.: 2014-07-29 14:05:10

Nice one, you rotate through Number pad until the input is all consumed.

Diksha Jaiswal: 2014-07-27 09:40:05

easy :)


Added by:Arjun Krishnan
Date:2014-03-13
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP JAVA PHP PYTHON