시간 제한메모리 제한제출정답맞은 사람정답 비율
40 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)24000.000%

문제

Let S be a string containing only letters of the English alphabet. An anagram of S is any string that contains exactly the same letters as S (with the same number of occurrences for each letter), but in a different order. For example, the word kick has anagrams such as kcik and ckki.

Now, let S[i] be the i-th letter in S. We say that an anagram of S, A, is shuffled if and only if for all i, S[i] ≠ A[i]. So, for instance, kcik is not a shuffled anagram of kick as the first and fourth letters of both of them are the same. However, ckki would be considered a shuffled anagram of kick, as would ikkc.

Given an arbitrary string S, your task is to output any one shuffled anagram of S, or else print IMPOSSIBLE if this cannot be done.

입력

The first line of the input gives the number of test cases, T. T test cases follow. Each test case consists of one line, a string of English letters.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a shuffled anagram of the string for that test case, or IMPOSSIBLE if no shuffled anagram exists for that string.

제한

  • 1 ≤ T ≤ 100.
  • All input letters are lowercase English letters.

Test Set 1 (4점)

  • 1 ≤ the length of S ≤ 8.

Test Set 2 (8점)

  • 1 ≤ the length of S ≤ 104.

예제 입력 1

2
start
jjj

예제 출력 1

Case #1: tarts
Case #2: IMPOSSIBLE

힌트

In test case #1, tarts is a shuffled anagram of start as none of the letters in each position of both strings match the other. Another possible solution is trsta (though you only need to provide one solution). However, in test case #2, there is no way of anagramming jjj to form a shuffled anagram, so IMPOSSIBLE is printed instead.

채점 및 기타 정보

  • 예제는 채점하지 않는다.