# 3626. Thinking-Bear's Necklace

Thinking-Bear gave a string of letters to the sister who admired in the heart. Sister looked at the string and said to Thinking-Bear: “I hope it is symmetrical”. Thinking-Bear decided to cut a continuous part from the original string and join to form a new necklace. A necklace is symmetrical if we can cut it into a palindrome.

Thinking-Bear can use magic. He can replace one letter to another letters. The magic can be used at most twice. Thinking-Bear want to know what’s the longest length of necklace he is able to capture. We assume that the length of the new necklace must be an odd number.

Note: This problem is different from the original Metropolitan problem in that the necklace being cut is joined to form a new necklace, instead of the remaining part.

### 输入

Th first line of the input is $T$ ($1 \le T \le 100$), which stands for the number of test cases you need to solve.

Each test case contains a string $S$, indicates the necklace. ($2 \le |S| \le 100~000$).

Notice: $|S|$ can be $2$. $\sum |S|$ for all tests does not exceed $10^6$.

### 输出

For each test case, output a number, meaning the longest length of symmetrical necklace he can capture.

### 样例

Input
1
abcdaaa

Output
7


### 提示

For the sample, he can replace one ltter to “abcbaaa”.

1 人解决，3 已尝试。

5 份提交通过，共有 15 份提交。

9.9 EMB 奖励。
{"extraction_info": {"found_math": true, "script_math_tex": 8, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6177106499671936, "perplexity": 1346.5431263658961}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-09/segments/1550247490225.49/warc/CC-MAIN-20190219142524-20190219164524-00578.warc.gz"}