QOJ.ac

QOJ

Time Limit: 4.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#14823. Chief Justice of Gensokyo

Statistics

Image source: Bad Apple!! PV [Shadow Art]

Shiki is a judge in Gensokyo who often records many texts with pen and paper. Shiki discovered that many English letters, such as o, v, and w, form ligatures when written. For example, two consecutively written v's join together to look like a w; consecutive v's and w's also join together, for example, wvvwvwv looks like a string of v's with a length of 10.

Shiki considers a string to be "good" if and only if its appearance when written on paper is perfectly mirror-symmetric. For example, wvowv is mirror-symmetric because it appears on paper as three sharp points, one circle, and three sharp points; whereas vowow is not symmetric.

Now, Shiki has given you a string $s$ that she recorded, guaranteed to consist only of letters from $\{o, v, w\}$. You need to find the longest "good" substring of $s$.

Input

There are multiple test cases. The first line contains an integer $T$ ($1 \le T \le 2 \times 10^6$) representing the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \le n \le 10^7$), representing the length of the string $s$.

The second line contains a string $s$ of length $n$, guaranteed to consist only of letters from $\{o, v, w\}$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^7$.

Output

For each test case, output a single line containing the longest "good" substring of $s$.

If there are multiple solutions, you may output any one of them.

Examples

Input 1

3
8
wwwovvvv
16
wwwooooooooovwww
11
wwwovoovvvv

Output 1

wwovvvv
ooooooooo
vvvv

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.