Smart Squirrel

0

0 votes
Problem

Problem

Since the Industrial Revolution, the global annual temperature has increased. This Climate change is a global phenomenon that largely impacts urban life and squirrels living in the cities. A smart squirrel lives in certain city in which temperature change is a real issue.

The squirrel collects food everyday and as soon as he gets another day having higher temperature than the collection day, he dries and finally preserves the food. The squirrel is busy thus he asked you to help him preserve his food collection.

The squirrel provided a notebook having temperature value of last n days. For each of the ith (1 <= i <= n ) provided days, you have to tell the squirrel the temperature value on which he can dry and preserve the collected food on ith day.

Input

First line contains T denoting the number of test cases.

For each test case 

    • The first line contains only one integer N denoting the length of the temperature array.
    • The second line of each test case contains N space-separated integers denoting the temperature array A. Ai th integer denotes the temperature on the ith day in the city.

Output

For each test case (in a separate line), print N space-separated integers. the ith (1 <= i <= n) integer denotes higher temperature than the ith day provided.

If you can’t find higher temperature for any of the ith (1 <= i <= n) days, ‘-1’ (without quotes) will be the integer you have to print for ith (1 <= i <= n) day.

Constraints

  • 1 <= T <= 102
  • 1 <= N <= 105
  • 1 <= A[i] <= 105
Time Limit: 0.5
Memory Limit: 256
Source Limit:
Editor Image

?