#C3036. Palindrome Rearrangement
Palindrome Rearrangement
Palindrome Rearrangement
You are given a string s consisting of lowercase English letters. Your task is to determine if the letters of s can be rearranged to form a palindrome.
A string is a palindrome if it reads the same backward as forward. For a string to be rearranged into a palindrome, at most one character can appear an odd number of times. In other words, if we denote the frequency of each character by \(f(c)\), then the condition for the string to be rearranged into a palindrome is:
[ \sum_{c \in s} [f(c) \mod 2 \neq 0] \leq 1 ]
If the string meets this condition, output Possible
, otherwise output Impossible
.
The input consists of multiple test cases. For each test case, process the string and print the result on a new line.
inputFormat
The first line of input contains an integer T
representing the number of test cases. Each of the next T
lines contains a single string s.
Input Format:
T s1 s2 ... sT
outputFormat
For each test case, print a single line containing Possible
if the string can be rearranged to form a palindrome; otherwise, print Impossible
.
Output Format:
result1 result2 ... resultT## sample
3
civic
ivicc
hello
Possible
Possible
Impossible
</p>