#K10401. Shift Cipher: Encryption and Decryption

    ID: 23238 Type: Default 1000ms 256MiB

Shift Cipher: Encryption and Decryption

Shift Cipher: Encryption and Decryption

You are given a message consisting of lowercase English letters and an integer shift. Your task is to either encrypt or decrypt the message using a Caesar cipher. In a Caesar cipher, each letter is shifted by a given value, wrapping around the end of the alphabet. Formally, if a letter is represented by an integer x (with 0 corresponding to 'a', 1 to 'b', and so on), then after shifting by an integer k, the new letter is given by

\( (x + k) \mod 26 \)

This operation should be reversed when decrypting. You need to implement the process based on the provided operation type.

inputFormat

The input is read from the standard input (stdin) and consists of three lines:

  • The first line contains a string, either encrypt or decrypt, indicating the operation.
  • The second line contains an integer shift.
  • The third line contains the message to be processed. The message is composed exclusively of lowercase English letters.

outputFormat

The output is written to the standard output (stdout). It should be a single line consisting of the resulting string after applying the specified operation.

## sample
encrypt
3
secure
vhfxuh