Link with Centrally Symmetric Strings
题号:NC254993
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Given a string, determine if it can be represented as the concatenation of several centrally symmetric substrings.

Formally, a string S is centrally symmetric if and only if it satisfies one of the following conditions:
  •  S is an empty string.
  •  S = o|s|x|z, i.e., S is one of the four letters: o, s, x and z.
  •  S = bSq|dSp|pSd|qSb|nSu|uSn|oSo|sSs|xSx|zSz, i.e., S starts and ends with a pair of centrally symmetric letters, and the middle part is also a centrally symmetric substring.

A string S is considered good if and only if there exists an integer n \geq 1 such that S = T_1T_2 \cdots T_n, where T_i (1 \le i \le n) is a centrally symmetric substring.

Given a string S, determine whether it is a good string.

输入描述:

The input contains multiple test cases.

The first line contains an integer T (1 \leq T \leq 10^6), indicating the number of test cases.

The following T lines each contain a string S (1 \leq |S| \leq 10^6) consisting of lowercase English letters, representing the string to be tested.

It is guaranteed that \sum |S| \leq 5 \times 10^6, where |S| represents the length of string S.

输出描述:

For each test case, if the string is good, output “Yes”; otherwise, output “No”.

You can output each letter in any case (lowercase or uppercase). For example, the strings “yEs”, “yes”, “Yes”, and “YES” will be accepted as a positive answer.
示例1

输入

复制
3
sosos
hahaha
sbzzq

输出

复制
Yes
No
Yes

说明

For the third test case, the string can be divided into two substrings, “s” and “bzzq”, both of which are centrally symmetric substrings. Therefore, the output is “Yes”.