KIT - Krypt in Time

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

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

hide comments
2014-05-13 23:03:39 freaker
@Arjun krishnan plz check my solution,i'm getting WA ,solution id-11570912...!!!


Last edit: 2014-05-13 23:05:24
2014-05-09 17:47:26 RIVU DAS
Too easy!!
2014-04-24 14:37:38 ivar.raknahs
AC in one go :
easy one but take care of spaces.
2014-04-17 14:47:30 sankar
@fitcat every ith element in the string is shifted to by corresponding ith element in the numberpad array(excluding spaces).

Last edit: 2014-04-17 14:48:25
2014-04-17 12:48:16 fitcat
@sankar: The example test case contains 10 numbers and there are exactly 10 characters in total. How can you figure it out?
2014-04-17 10:44:33 sankar
@fitcat: I figured it out from the example cases itself. Got acc now. Anyways thank u for ur reply :)
2014-04-17 10:17:45 fitcat
@sankar: From the forum, someone told me that you should start at the beginning of the number pad. I can't figure it out by just reading the problem description. I'm glad I'm not alone.
2014-04-17 09:11:26 sankar
What to do if all the numbers in the number pad are used but the string is not over yet
2014-04-16 22:55:39 LeppyR64
@Lakshman: The maximum length is not needed.
2014-04-16 16:09:04 [Lakshman]
@Arjun Krishnan what is the max length of the input string?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.