Casino

No attempts yetTime limit1sMemory limit128 MB

Problem

Dalia is the assistant director of the fundraising team at the ACPC. This year is going badly. Sponsors are nowhere near enough. If nothing changes, the teams get no balloons, no T-shirts, not even name tags.

Dalia knows that signing a sponsor now is too late, and that doing anything at all is too late. She does not give up. She decides to gamble instead. A casino nearby has just introduced a new game, and she thinks she has a real chance at it.

The rules are simple. The dealer lays out a long row of cards on the table that spells one string, and Dalia has to point out every palindrome in that string that has length 2 or more and is as long as possible. A palindrome reads the same forward and backward, and a maximum length palindrome is one that no longer palindrome in the string beats. So if the maximum palindrome length in the string is X>1X > 1, print every palindrome of length XX in the string.

Input

The first line contains the number of test cases TT. Each test case is one line holding a non-empty string SS of lowercase English letters. The length of SS is at most 1000.

Output

For each test case, first print the case number in the form Case #k:, where kk counts from 1. Then print the palindromes of length XX that occur in SS, one per line, where XX is the maximum palindrome length in SS.

Order and duplicates work like this. Find every position where a palindrome of length XX occurs, then print those occurrences by starting position, rightmost first and moving left. If the same string occurs at two different positions, print it twice.

If X=1X = 1, that is, if SS contains no palindrome of length 2 or more, print only the case number line and no palindrome.