#K80572. Single-Character Transformation
Single-Character Transformation
Single-Character Transformation
You are given a string S consisting of lowercase English letters. Your task is to determine whether it is possible to transform the string S into a string in which every character is the same by using the allowed operations.
The allowed operation is defined implicitly: if all characters in the string are the same, then the string is already transformed into a single-character string. Otherwise, transformation is not possible.
In other words, if every character in S is identical (i.e. S = cccc\cdots c for some character c), then output c. Otherwise, output IMPOSSIBLE
.
Note: All formulas are rendered in \(\LaTeX\) format. For example, if all characters in \(S\) are the same, then \(S=c\times n\) for some character \(c\) and integer \(n\geq1\).
inputFormat
The first line of input contains an integer \(Q\) (\(1 \le Q \le 100\)) denoting the number of test cases.
For each test case, there is one line containing a non-empty string \(S\) (\(1 \le |S| \le 10^5\)) consisting of lowercase English letters.
Input should be read from stdin
.
outputFormat
For each test case, output a single line which is either the single character if all characters in \(S\) are identical, or IMPOSSIBLE
if it is not possible to transform \(S\) into a single-character string.
Output should be written to stdout
.
1
a
a
</p>