JUNL - BHAAD MEI JAAO

You are on vacation on a drunken island, but you couldn't resist the temptation of solving a good old problem. It all started when a group of kids played a game they call "The Falling Coconuts". In this game, a number of coconuts fall to the ground, one by one, on a single axis, at the locations given in drops. If a coconut X lands on the ground, it remains where it is. If it lands on top of another coconut Y, one of the following things happens:

If coconut Y is surrounded on both sides by coconuts (denoted by 'O'), coconut X remains where it is.

     X
    OYO

If there is no coconut directly to the right of coconut Y, coconut X slides down to the position directly to the right of coconut Y.

     X
    OY   ->  OYX
     X
     Y   ->   YX

If there is a coconut directly to the right of coconut Y, but no coconut directly to the left of coconut Y, coconut X slides down to the position directly to the left of coconut Y.

    X
    YO  ->  XYO

Each time coconut X slides down to a different position, it will continue to slide (following the behavior outlined above) until it's in a place where it will not slide any further.

The task is to display the final coconut configuration.

Input

First line is t = number of test cases.

Each test case consists of 2 lines, first line conataining the number of coconuts and second line contains n integers denoting the position of each coconut on the x-axis.

Output

As described in the problem statement.

Example

Input:
2
8
8 9 10 11 12 8 12 10
10
6 8 10 7 9 8 8 8 8 8

Output:
---O---
OOOOOOO
--O---
-OOO--
OOOOOO

Explanation of test case 1:

The configuration after each fallen coconut is given below:

X  ->  OX  ->  OOX  ->  000X  ->  0000X  ->  X00000  ->  000000X  ->  0000000

In this diagram, 'X' denotes the last fallen coconut.


Added by:Aradhya
Date:2012-10-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:AVIRAL,YASH,AMAN,ARADHYA

hide comments
2019-11-19 08:57:01 Simes
For a similar but harder problem, try BGRAVITY.
2019-11-18 20:33:18
Props to Jared Deckard for clarification, but resting position is 0 ≤ Ri ≤ 27.

Fun problem, poorly set.

Last edit: 2019-11-18 20:33:36
2019-08-25 11:55:00
BHAAD MEI JAO Problem Setter, AC in one go ho gaya
2014-07-06 19:41:33 Nitesh Tiwari
Is it just me or there really something fishy about the about the output of the 2nd test code. Isn't it should like this

--00-
-ooo-
ooooo

Please help if I am mistaken it.

Last edit: 2014-07-06 20:09:59
2014-06-09 22:26:06 Rishav Goyal
Awesome problem. Description is also correct. If need refer Jered's comment.
2014-06-05 15:40:29 amarveer
There are no extra lines in input and output.
2013-07-10 14:35:29 Mayank gupta
very bad description...:(
though AC:)
2013-01-27 06:25:49 Shubham
good problem but description sucks.
2012-11-12 02:13:02 david_8k
Topcoder for this task.
2012-10-17 06:11:59 Nitin Khanna
@Jared : Thanks it is more than enough.I completely misunderstood the problem.If you wish you can remove the link.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.