1040:Foney's cryptographic systems

Time/Memory Limit:1000 MS/32768 K
Submitted: 30 Accepted: 7

 Problem Description

<div> Foney started to use a new cryptographic systems, Surprisingly it is not a RSA, its encoding and decoding is based on secret keys.Foney chose as a secret key a sequence of n distinct integers, a1 ; . . .; an, greater than zero and less or equal to n. The encoding is based on the following principle.Character in the message at the position i is written in the encoded message at the position ai, where ai is the corresponding number in the key.This process is repeated k times. After kth encoding is Foney wants.Now Foney wants to encode his message,you should help he to get the message after kth encoding.</div>

 Input

The input file consists of several blocks.Each block has a number n(0&lt;n&lt;=200), The next line contains a sequence of n distinct integers, a1 ; . . .; an, greater than zero and less or equal to n.Next lines contain integer number k(0&lt;k&lt;10^9) and one message of ascii characters separated by one space. The block ends with the separate line with the number 0. After the last block there is in separate line the number 0.<br />

 Output

Each block contains the encoded input messages in the same order as in input file. Each encoded message in the output file has the lenght n. After each block there is one empty line.<br />

 Sample Input

12
4 5 3 7 2 8 1 6 10 9 12 11
1 foney&money
999939 zsacm ^-^
0
4
1 2 3 4
1 abc
0
0

 Sample Output

mynfooe&en y
zmacs-^  ^

abc

 Hints

1

 Author

foney

 Source

1

 Recommend

zh