Palindrome String


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
C++, Python

Palindrome Construction Problem

Xiao Lan is recently fascinated by palindromic strings. He has a string S containing only lowercase letters. Xiao Lan can add any number (including zero) of the specified characters l, q, b (ASCII codes 108, 113, 98 respectively) to the beginning of S.

He wants to know whether he can transform S into a palindrome by doing so.

Input Format

  • The first line contains an integer T, indicating the number of test cases.
  • The next T lines each contain a string S, describing the test data.

Output Format
Output T lines, each containing a string:

  • If S can be transformed into a palindrome, output Yes.
  • Otherwise output No.

Data Range

  • For 50% of test cases, 1 ≤ |S| ≤ 1000, where |S| is the length of S.
  • For all test cases, 1 ≤ T ≤ 10, 1 ≤ ∑|S| ≤ 106.

Sample Input

3
gmgqlq
pdlbll
aaa

Sample Output

Yes
No
Yes

Sample Explanation

  • For gmgqlq, add qlq at the front → qlqgmgqlq, which is a palindrome.
  • For pdlbll, it cannot be transformed into a palindrome.
  • For aaa, it is already a palindrome.

Comments

There are no comments at the moment.