SMPCPH1  Substitution cipher
You are given a sequence of n characters S = s_{1}, s_{2}, ..., s_{n} in such a way that for i ≠ j we have also s_{i} ≠ s_{j}. Your task is to substitute every s_{i} with s_{i+1} for i in {1, 2, ... n1} and s_{n} with s_{1} in the given plain text.
Input
In the first line you are given one integer 2<=n<=26, and in the following line n characters.
In the third line you are given one integer 2<=m<=100, and in the following m lines you are given a plaintext to be encoded. Plaintext contains only white spaces and small letters from the Latin alphabet. The whole plain text is at most 1000 characters long.
Output
Encoded text, as specified above.
Example 1
Input: 6 spojit 3 after this training we will solve even difficult and tricky problems easily Output: afser shtp sratntng we wtll pjlve even dtfftculs and srtcky orjblemp eaptly
Example 2
Input: 10 dontgiveup 3 after this training we will solve even difficult and tricky problems easily Output: afgur ghvs gravtvti wu wvll snleu ueut ovffvcplg ato grvcky drnblums uasvly
hide comments
ravalidarla:
20180919 14:22:23
i did not understand the question,can any on explain it...plz Last edit: 20180919 14:22:57 

shivam_mnnit:
20170508 18:07:33
how to input string characterwise?? 

codingboy:
20160802 09:17:18
I don't know what's going on.. my result in my local compiler is the same as the example. anyone could give me a suggestion? 

xinnix:
20160605 08:13:23
Ah... There's a \n after every line and I was checking what's wrong for 5WAs 
Added by:  kuszi 
Date:  20140123 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 