Problem Description

Rar the Cat is feeling weird today. He decided to text his girlfriend with using words that are spelled backwards.

For example: " RaWR I'm a Dinosaur! " will become " RwAR I'm a Ruasonid! "

Since it is hard to reverse or revert words that are spelled in reverse, he wants you to write a program to do it for him.

For clarity, words are defined as consecutive characters with each character being one of the following: A-Z, a-z.

The positions of punctuation marks and numbers (including apostrophes) should remain the same and the capitalization of the letters should remain the same (Eg: If the first letter is capitalized, the first letter of the reversed word should be capitalized as well).


A single line, (with spaces and punctuations) consisting of not more than 1,000,000 characters.


A single line, the reversed line of the input.


Subtask 1 (20%) will only consist of lowercase letters and spaces.

Subtask 2 (40%) will not consist uppercase letters

Subtask 3 (40%) will contain both uppercase and lowercase letters as well as numbers and punctuation marks.

Subtask 4 (0%) will be the sample testcases

Sample Testcase 1


RaWR I'm a Dinosaur!


RwAR I'm a Ruasonid!

Sample Testcase 2