#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 ovw\texttt{ovw}, will form ligatures when written. For example, two consecutive handwritten v\texttt{v} connected together look like w\texttt{w}; consecutive v\texttt{v} and w\texttt{w} will also connect together. For example, wvvwvwv\texttt{wvvwvwv} looks like a chain of v\texttt{v} with length 1010.

Shiki thinks a string is good if and only if, when written on paper, it is a perfect mirror image. For example, wvowv\texttt{wvowv} is mirrored, because when written it is three sharp corners, one circle, and three sharp corners; while vowow\texttt{vowow} 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 ss that she recorded, and it is guaranteed that ss only consists of ovw\texttt{ovw}. You need to find a longest substring of ss such that this substring is good.

Input Format

The first line contains an integer TT, the number of test cases.

Then for each test case:

The first line contains an integer nn (1n1071 \le n \le 10^7), the length of the string ss.

The second line contains a string ss of length nn, guaranteed to consist only of ovw\texttt{ovw}.

It is guaranteed that n107\sum n\le 10^7 over all test cases.

Output Format

For each test case, output one line containing a string, representing a longest good substring of ss.

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