All Tracks Algorithms String Algorithms Basics of String Manipulation Problem

Secret Messages!
/

String

Problem
Editorial
Analytics

X and Y are best friends and they love to chat with each other. But their recent concerns about the privacy of their messages has distant them. So they decided to encrypt their messages with a key, K, such that the character of their messages are now shifted K times towards right of their initial value. Their techniques only convert numbers and alphabets while leaving special characters as it is.

Provided the value K you are required to encrypt the messages using their idea of encryption.

INPUT FORMAT

The first line of the input contains, T, the number of messages. The next line contains N, and K, no of characters in the message and key for encryption. The next line contains the message.

OUTPUT FORMAT

Output the encrypted messages on a new line for all the test cases.

CONSTRAINS

\(1\le T \le 100\)
\(1\le N \le 10^{6}\)
\(0\le K \le 10^{6}\)

SAMPLE INPUT
2
12 4
Hello-World!
16 50
Aarambh@1800-hrs
SAMPLE OUTPUT
Lipps-Asvph!
Yypykzf@1800-fpq
Explanation

For the first test case, the message is "Hello-World!". Shifting "H" towards right by 4 we get "L", similarly sifting "ello" by 4 each we would get "ipps". Now since "-" is a special character we do not need to encrypt this character. After that we have "W" shifting "W" by 4 we come at "A", simlilarly shifting "orld" by 4 each we get "svph" and the last character is again a special character "!" so we do not encrypt this character.

For the second test case, we have "Aarambh@1800-hrs" we shift "A" by 50 which brings us to "Y" after 1 full circular rotation, the next character of the message is "a" which will be encrypted to "y", similarly "rambh" is encrypted in the same manner giving us "pykz". The next character is a special character "@", after that we have "1", shifting "1" by 50 we get "1" itself and similarly encrypting "800" gives us "800". The next character is again a special character "-", after which we have "hrs" which on encrypting will give is "fpq".

Time Limit: 0.5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?