AMR12D - The Mirror of Galadriel

With water from the stream Galadriel filled the basin to the brim, and breathed on it, and when the water was still again she spoke. 'Here is the Mirror of Galadriel,' she said. 'I have brought you here so that you may look in it, if you will. For this is what your folk would call magic, I believe; though I do not understand clearly what they mean; and they seem also to use the same word of the deceits of the Enemy. But this, if you will, is the magic of Galadriel. Did you not say that you wished to see Elf-magic?' - Galadriel to Frodo and Sam, describing her Mirror.

We call a string S magical if every substring of S appears in Galadriel's Mirror (under lateral inversion). In other words, a magical string is a string where every substring has its reverse in the string.

Given a string S, determine if it is magical or not.

Input

The first line contains T, the number of test cases. The next T lines contain a string each. 

Output

For each test case, output "YES" if the string is magical, and "NO" otherwise.

Constraints

1 <= T <= 100
1 <= |S| <= 10
S contains only lower-case characters.

Example

Sample Input:
2
aba
ab

Sample Output:
YES
NO

Notes / Explanation of Sample Input

For the first test case, the list of substrings are : a, b, ab, ba, aba. The reverse of each of these strings is present as a substring of S too.

For the second test case, the list of substring are : a, b, ab. The reverse of "ab", which is "ba" is not present as a substring of the string.


Added by:Varun Jalan
Date:2012-12-22
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Varun Jalan - ICPC Asia regionals, Amritapuri 2012

hide comments
2013-06-30 17:47:58 BroadSword
well, it appears that strrev() in C is not allowed here...judge must be Linux
2013-06-08 01:35:04 Chandan Mittal
tutorial stuff :)
2013-04-06 15:10:16 marwan akkad
very easy
2013-02-24 14:08:14 Rajat Shah
really the easiest one :)
2013-01-30 20:29:37 Ankit Chaudhary
very easy problem
2013-01-26 15:37:17 suyog patil
easy
2013-01-10 15:39:41 (Tjandra Satria Gunawan)(曾毅昆)
after this you may try The BrainFast Processing! Classical version or The BrainFast Processing! Challenge version
2013-01-08 18:02:33 abdelkarim
easy one !!
2013-01-07 16:13:00 Vipul Pandey
just use inbuilt c++ string functions
2013-01-04 18:17:00 Govind Lahoti
really very easy
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.