#K38147. Reverse and Swap Case

    ID: 26134 Type: Default 1000ms 256MiB

Reverse and Swap Case

Reverse and Swap Case

You are given a string s. Your task is to reverse the string and swap the case of each alphabetical character. That is, every uppercase letter should become lowercase and vice versa. Non-alphabetical characters remain unchanged.

Mathematically, if the input string is represented as \(s = s_1 s_2 \dots s_n\), then the output should be \(t = t_1 t_2 \dots t_n\) where \(t_i = \text{swap}(s_{n-i+1})\). The \(\text{swap}(c)\) function converts a lowercase letter to uppercase and an uppercase letter to lowercase, leaving non-alphabetical characters as they are.

For example, if s = "Hello, World!", then the reversed string is "!dlroW ,olleH" and after swapping cases it becomes "!DLROw ,OLLEh".

inputFormat

The input consists of a single line containing the string s. The string may include spaces, digits, letters, and special characters.

outputFormat

Output the resulting string after reversing the input string and swapping the case of all alphabetical characters.

## sample
Hello, World!
!DLROw ,OLLEh