Best String

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 3504
64-bit integer IO format: %I64d      Java class name: Main

Description

Given a string, you use some letters or digits to creat a new string, this new string have three properties.
1. any two adjacent letter aren't the same.
2. the new string have the biggest length.
3. the new string have the biggest lexicographical ordering.

Input

The input consists of multiple test cases. Each test case contain a string, the string is consist of 'a'~'z', 'A' - 'Z' and '0' - '9'. the length of string is not exceed 500.

Output

For each case, print the new string.

Sample Input

2
abaa
001

Sample Output

aba
010

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .