Encryption Decryption

4.5

2 votes
Easy
Problem

Given an encrypted string and a key value you need to decrypt the string.

Rules for Decryption

0 <= Key <= 51
The encrypted message only consists of a-z, A-Z, and '.'
'.' is decrypted as a space character
If key lies between 0 and 25, then the character is added with the key and modulo is taken and the case is maintained. For eg, if key is 3, then a is decrypted to d and z is decrypted to c.
If key lies between 26 and 51, then the character is added with the key and modulo is taken and the case is inverted. For eg, if key is 29, then a is decrypted to D and z is decrypted to C.

Input

First line consists of t, the number of test cases. (1<=t<=20)
For each test case, first line consists of key. 0<=key<=51
Second line consists of the encrypted message S. length of S <= 106

Sample Input
1
2
dsz.dsf
Sample Output
fub fuh
Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?