#P15561. [CCPC 2025 哈尔滨站] 幻想乡的裁判长
[CCPC 2025 哈尔滨站] 幻想乡的裁判长
Problem Description
:::align{center}

Image source: Bad Apple!! PV【影絵】 :::
Shiki is a judge in Gensokyo and often needs to write down a lot of text with pen and paper. Shiki found that many English letters, such as , will form ligatures when written. For example, two consecutive handwritten connected together look like ; consecutive and will also connect together. For example, looks like a chain of with length .
Shiki thinks a string is good if and only if, when written on paper, it is a perfect mirror image. For example, is mirrored, because when written it is three sharp corners, one circle, and three sharp corners; while is not symmetric, because on its leftmost side there are two sharp corners, but on the right side there are three.
Now Shiki gives you a string that she recorded, and it is guaranteed that only consists of . You need to find a longest substring of such that this substring is good.
Input Format
The first line contains an integer , the number of test cases.
Then for each test case:
The first line contains an integer (), the length of the string .
The second line contains a string of length , guaranteed to consist only of .
It is guaranteed that over all test cases.
Output Format
For each test case, output one line containing a string, representing a longest good substring of .
If there are multiple answers, you may output any one of them.
3
8
wwwovvvv
16
wwwooooooooovwww
11
wwwovoovvvv
wwovvvv
ooooooooo
vvvv
Hint
Translated by ChatGPT 5