#K66452. Rearrange String for Cryptographic Encryption

    ID: 32423 Type: Default 1000ms 256MiB

Rearrange String for Cryptographic Encryption

Rearrange String for Cryptographic Encryption

Sophia, an enthusiastic cryptographer, is developing a new encryption algorithm that involves rearranging the characters in a string. The goal is to shuffle the string so that no two adjacent characters are the same. Formally, for any valid rearrangement \( R \) of string \( S \), it must hold that \( R[i] \neq R[i+1] \) for all indices \( i \). If such an arrangement is impossible, your program should output IMPOSSIBLE.

The input string is provided on standard input (stdin) and the output should be printed to standard output (stdout). The input string consists of lowercase English letters only.

inputFormat

The input consists of a single line containing the string \( S \).

outputFormat

Output a single line containing a rearranged string such that no two adjacent characters are the same. If no such rearrangement exists, output IMPOSSIBLE.

## sample
aab
aba