SP24258 DRUIDEOI - Fata7y Ya Warda!

Description

Druid (AKA Amr Alaa El-Deen) and little EOIers have finished their training and they are playing "Fatta7y ya warda!". It's a kids game when everyone holds hands with two other kids forming a circle, and they keep saying "Fatta7y ya warda!" (Flourish, flower!) (moving away from each other, while still holding hands, to form a huge circle), then "2affely ya warda!" (Die, flower!) (moving back as close to each other as possible, while still holding hands, to form a tiny circle, i.e. a point). That's it! Anyway the point is... While Eagle (AKA Mohamed Ahmed) was watching them playing he was wondering, who's the first person taller than Druid on his left? Similarly, who's the first person taller than Druid on his right? Help Eagle find the answer for each person not just Druid.

Input Format

The input starts with an integer _T_ (1 _T_ 20), the number of test cases. Each test case contains two lines. The first line contains a single integer _N_ (1 N ), the number of persons playing the game. The second line contains _N_ integers _h_ $ _{i} $ (1 h $ _{i} $ ) the height of the _i_-th person. They are numbered 1 to _N_ starting from Druid.

Output Format

For each test case print _N_ lines, in the _i_-th line print 2 numbers, the index of the first person taller than the _i_-th person on his left, and the index of the first person taller than the _i_-th person on his right. If no one is taller than the _i_-th person print -1 -1.