SEAGOD - Searching God

no tags 

Jesse is a biologist and he was studying some aspects of life when he discovered that certain species of sea animals tried to tell him some things about God. Those animals were using a certain language to speak with him. They wrote down in binary code (black and white) in the shell they have. As Jesse was the only one that this message was intended to be delivered, they encrypted the message in such way that there is a rule to decrypt every bit in the spherical-shaped shell looking at 3 other bit: the left, itself and the right in this order. So first they write the cyphered message and the rule to decrypt it in lexicographical order, so the rule space in the shell containing the bit to decrypt “101” will be rule's bit 5. To turn the cryptography more elaborated there is also the number of rounds that this must be done to the entire message. Jesse wants to hire you to write a program for him to decrypt the text and live in harmony forever and ever with the animals he loves and find out who is and what this God wants to do.

Input

The input has several test cases. The first line of a test case contains the message length L (0 < L ≤ 10000). The next line contains the message M, of length L bits. In the next line, your program should read the 8-bits rule R. In another line, the number of rounds 0 ≤ N ≤ 10000. Your program must read until the end of file.

Output

For each test case your program must write the message M after applying the rule R for N rounds.

Example

Input:
5
10111
10101010
1
10
1011010101
11100010
2 Output: 10000
1011010101

hide comments
sashuk_keshuk: 2023-08-13 19:47:49

авахвхавхавх виталя

somegenuisuser: 2023-08-12 23:51:08

Dont ban me. Im from jasnah

Sardar Khan: 2012-06-05 10:29:22

nice n easy :)

BOND: 2012-03-14 14:09:08

do not use hash. i got hell lot of tle because of that.

Aman Kumar: 2012-03-09 14:12:02

anyone explain the test cases..? how is the decrypting done....lexicographically..

Last edit: 2012-03-09 18:00:32
Aman Kumar: 2012-03-09 13:38:41

how to end the input..?

* da Trypanossoma: 2012-02-10 16:01:57

the message is cyclic? In the 2nd example, isn't the answer the result of only 1 round?

Los Desempleados FIIS: 2012-02-10 16:01:57

how do you handle the first and last bit?


Added by:Paulo Costa
Date:2012-02-10
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:UFU