One of the Czech ministers wants to run for the chair in the European Parliament. Now he is preparing his election campaign, which is based on the following simple program: that people should behave well, be nice to each other, and live on good business only. For this purpose, he needs some mottos in English language. For example, the motto he likes most is `Live on no evil'' because of its special property: it says the same thing when read backwards! Such strings are called palindromes.
The minister wants to find more palindromic sentences and mottos, such as `Rats live on no evil star'', `Was it a car or a cat I saw?'', etc. You are to write a computer program which is able to detect not only palindromes but also so called mirrored strings. With that program, he can produce more great mottos and then easily win the election.
A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.
A mirrored string is a string for which when each of the elements of the string is changed to its reverse (if it has a reverse) and the string is read backwards the result is the same as the original string. For example, the string "3AIAE" is a mirrored string because "A" and "I" are their own reverses, and "3" and "E" are each others' reverses.
A mirrored palindrome is a string that meets the criteria of a regular palindrome and the criteria of a mirrored string. The string "ATOYOTA" is a mirrored palindrome because if the string is read backwards, the string is the same as the original and because if each of the characters is replaced by its reverse and the result is read backwards, the result is the same as the original string. Of course, "A", "T", "O", and "Y" are all their own reverses.
A list of all valid characters and their reverses is as follows. Note that `0'' (zero) and `O'' (the letter) are considered the same character and therefore only the letter `O'' is a valid character.
A |
A |
B |
|
C |
|
D |
|
E |
3 |
F |
|
G |
|
H |
H |
I |
I |
J |
L |
M |
M |
N |
|
O |
O |
P |
|
Q |
|
R |
|
S |
2 |
T |
T |
U |
U |
V |
V |
W |
W |
X |
X |
Y |
Y |
Z |
5 |
1 |
1 |
2 |
S |
3 |
E |
4 |
|
5 |
Z |
6 |
|
7 |
|
8 |
8 |
9 |
|