#K71827. Caesar Cipher

    ID: 33618 Type: Default 1000ms 256MiB

Caesar Cipher

Caesar Cipher

You are required to implement a Caesar cipher that encodes or decodes a given string based on a given shift value. In a Caesar cipher, each alphabetical character in the string is shifted by a fixed number of positions. The shift is applied independently on uppercase and lowercase letters. Non-alphabetical characters remain unaffected.

For an alphabetical character c, if its index in the alphabet is denoted by \(i\) (where \(i = 0\) corresponds to 'a' or 'A'), then its transformed index is calculated as:

[ i_{new} = (i + k) \mod 26 ]

and the resulting character is determined by converting \(i_{new}\) back to a letter preserving the case.

Your task is to read the input from stdin and output the result to stdout.

inputFormat

The input consists of two lines:

  • The first line contains the string S, which may include alphabetic characters, digits, spaces, and punctuation.
  • The second line contains an integer k, representing the shift value in the cipher. The value k can be positive, negative, or zero.

outputFormat

Print the resulting string after applying the Caesar cipher transformation to S.

## sample
middle-Outz
2
okffng-Qwvb