#K226. Reverse and Invert Case

    ID: 24697 Type: Default 1000ms 256MiB

Reverse and Invert Case

Reverse and Invert Case

You are given an integer (n) and (n) strings. For each string, you need to reverse the string and invert the case of every alphabetical character. This means that every uppercase letter is converted to lowercase and every lowercase letter is converted to uppercase.

For example, if the string is "Hello", after reversing it becomes "olleH" and inverting the case gives "OLLEh".

The transformation of a string (S = s_1s_2\cdots s_m) can be expressed mathematically as:
(T(i)=\text{invert}(s_{m-i+1})), where (\text{invert}(c)) is defined as:
(\text{invert}(c)=\begin{cases}\text{lowercase}(c) & \text{if } c \text{ is uppercase}\\text{uppercase}(c) & \text{if } c \text{ is lowercase}\ c & \text{otherwise}\end{cases}).

inputFormat

The input is read from standard input:\nThe first line contains a single integer (n) denoting the number of strings. Each of the following (n) lines contains one non-empty string which may include letters, digits, and symbols.

outputFormat

For each input string, output its transformed version (i.e., reversed with inverted case) on a new line to standard output.## sample

1
Hello
OLLEh

</p>