|All-time Popular Problems|
|Delete Middle of Linked List|
|Find all four sum numbers|
|Find first set bit|
|Element with left side smaller and right side greater|
|Smallest Positive missing number|
|Intersection Point in Y Shapped Linked Lists|
|Largest Number formed from an Array|
|Reverse an Array|
Given an integer array, for each element in the array check whether there exist a smaller element on the next immediate position of the array. If it exist print the smaller element. If there is no smaller element on the immediate next to the element then print -1.
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case contains an integer N, where N is the size of array.
The second line of each test case contains N integers sperated with a space which is input for the array arr[ ]
For each test case, print in a newline the next immediate smaller elements for each element in the array.
1 ≤ T ≤ 100
1 ≤ N ≤ 500
1 ≤ arr[i] ≤ 1000
4 2 1 5 3
5 6 2 3 1 7
2 1 -1 3 -1
-1 2 -1 1 -1 -1