Read problems statements in [Hindi], [Mandarin Chinese], [Vietnamese], and [Bengali] as well.

Dr. Chef is treating COVID-19 patients. There is a queue of $N$ patients (numbered from patient $1$ at the front of the queue to patient $N$ at the back) outside his clinic. You, his assistant, found out that for each valid $i$, the $i$-th patient has an *illness level* $A_{i}$.

Chef treats patients based on their health, i.e. a patient with a higher illness level is always treated before any patients with a lower illness level. Chef is also fair, so he treats patients with an equal illness level based on their position in the queue, i.e. a patient ahead in the queue is always treated before a patient with the same illness level that is further behind in the queue.

The first patient to be treated has to wait an hour for Chef to set up his equipment. Treating each patient also takes an hour, and Chef always starts treating the next patient as soon as he is done with the current one.

The patients are a bit impatient. As Chef's assistant, for each patient, find out how long (in hours) this patient needs to wait before Chef starts treating this patient.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.

------  Output ------
For each test case, print a single line containing $N$ space-separated integers. For each valid $i$, the $i$-th of these integers should be the time the $i$-th patient needs to wait.

------  Constraints ------
$1 ≤ T ≤ 5$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 1,000$ for each valid $i$

----- Sample Input 1 ------ 
4
5
2 3 5 3 4
3
2 2 2
6
2 10 3 3 2 10
4
8 9 8 9
----- Sample Output 1 ------ 
5 3 1 4 2
1 2 3
5 1 3 4 6 2
3 1 4 2
----- explanation 1 ------ 
Example case 1: Patient number $3$ has the highest illness level. Therefore, this patient just waits an hour for Chef to set up his equipment and gets treated immediately after. Patient number $5$ has the next highest illness level, so they go next. They need to wait an hour for patient $3$ to be treated. In total, patient $5$ has to wait $2$ hours. After that, both patients $2$ and $4$ have an equal illness level, but patient $2$ is ahead in the queue, so patient $2$ goes next, followed by patient $4$, and then finally patient $1$.

Example case 2: All three patients have the same illness level, so they are treated according to their position in the queue. Patient $1$ goes first, followed by patient $2$, and then patient $3$.

Example case 3: Patients at positions $2$ and $6$ in the queue have the highest illness level $10$. The patient at position $2$ is ahead in the queue, so this patient is treated first, and then the patient at position $6$ is treated. After this, the patients at positions $3$ and $4$ in the queue have the next highest illness level, so the patient at position $3$ is treated next, followed by the patient at position $4$. Similarly, afterwards, the patient at position $1$ is treated, and then the patient at position $5$ is treated.

Example case 4: Patients at positions $2$ and $4$ in the queue have the highest illness level $9$, so the patient at position $2$ is treated first, followed by the patient at position $4$, then the patient at position $1$ and finally the patient at position $3$.

Difficulty: MEDIUM_HARD

Solutions:
from collections import deque
from collections import defaultdict
for _ in range(int(input())):
	queue = deque()
	maxsick = 0
	n = int(input())
	sickness = list(map(int, input().split()))
	A = [[] for _ in range(1000)]
	for i in range(n):
		A[1000 - sickness[i]] += [i]
	ans = [0] * n
	t = 1
	for i in range(len(A)):
		for j in A[i]:
			ans[j] = t
			t += 1
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	patients = []
	for i in range(n):
		patients.append((a[i], n - i))
	patients.sort(reverse=True)
	wait = [0 for i in range(n)]
	for j in range(n):
		p = patients[j]
		wait[n - p[1]] = j + 1
	print(*wait)


import sys
from collections import Counter, defaultdict, deque
from math import gcd, sqrt, ceil

def li():
	return [int(i) for i in sys.stdin.readline().split()]

def si():
	return sys.stdin.readline().split()

def ii():
	return int(sys.stdin.readline())

def ip():
	return input()
for tastcas in range(int(input())):
	n = ii()
	a = li()
	ans = [0] * n
	l = []
	for j in range(n):
		l.append([-a[j], j])
	l.sort()
	curr = 1
	for j in l:
		ans[j[1]] = curr
		curr += 1
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0] * n
	l = []
	for j in range(n):
		l.append([-a[j], j])
	l.sort()
	cur = 1
	for j in l:
		ans[j[1]] = cur
		cur += 1
	print(*ans)


from collections import defaultdict

def main():
	try:
		numtest = int(input())
		for test in range(numtest):
			N = int(input())
			inputValue = list(map(int, input().split()))
			sol = resolve(inputValue)
			print(*sol)
	except EOFError:
		return

def resolve(sequence: list):
	n = len(sequence)
	sol: list = [0] * n
	dic: dict[int, list] = defaultdict(list)
	for i in range(n):
		dic[sequence[i]].append(i)
	sequence.sort()
	for elem in sequence:
		sol[dic[elem].pop()] = n
		n -= 1
	return sol
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	k = [0] * n
	r = sorted(list(set(a)), reverse=True)
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = [i]
		else:
			d[a[i]].append(i)
	cnt = 1
	for i in r:
		for j in d[i]:
			k[j] = cnt
			cnt += 1
	print(' '.join(map(str, k)))


import sys
import math
try:
	t = int(input())
	for x in range(t):
		n = int(input())
		arr = [int(x) for x in input().split()]
		dic = {}
		for i in range(len(arr)):
			if arr[i] in dic:
				dic[arr[i]] += [i]
			else:
				dic[arr[i]] = [i]
		wait = 1
		for k in sorted(dic.keys(), reverse=True):
			for i in dic[k]:
				arr[i] = wait
				wait += 1
		print(*arr)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = list(enumerate(l))
	l = sorted(l, key=lambda x: x[1], reverse=True)
	l2 = [0] * len(l)
	rank = 1
	for i in l:
		l2[i[0]] = rank
		rank += 1
	print(*l2)


t = int(input())
for i in range(t):
	n = int(input())
	line = list(map(int, input().split()))
	line_copy = sorted(line, reverse=True)
	data = {}
	for i in range(n):
		if line_copy[i] not in data:
			data[line_copy[i]] = i + 1
	for i in range(n):
		time = data[line[i]]
		data[line[i]] += 1
		line[i] = time
	print(*line, sep=' ')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
for _ in range(int(input())):
	(n,) = inp()
	a = inp()
	arr = []
	for i in range(n):
		arr.append([a[i], i])
	arr.sort(key=lambda x: (-x[0], x[1]))
	res = [0] * n
	time = 1
	for (val, ind) in arr:
		res[ind] = time
		time += 1
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	a = enumerate(list(map(int, input().split())))
	b = sorted([(-x, i) for (i, x) in a])
	c = [None] * n
	for i in range(n):
		c[b[i][1]] = i + 1
	print(' '.join(map(str, c)))


import sys
from collections import *
import math
import bisect

def input():
	return sys.stdin.readline()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dic = defaultdict(list)
	for i in range(n):
		dic[a[i]].append(i)
	cnt = 1
	ind = [0 for _ in range(n)]
	ll = sorted(list(dic.keys()), reverse=True)
	for i in ll:
		for j in dic[i]:
			ind[j] = cnt
			cnt += 1
	print(*ind)


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	reqli = sorted(li, reverse=True)
	c = 1
	freq = {}
	for i in reqli:
		if i in freq:
			freq[i].append(c)
		else:
			freq[i] = [c]
		c = c + 1
	ans = []
	for i in li:
		ans.append(freq[i][0])
		freq[i].remove(freq[i][0])
	for i in ans[:len(ans) - 1]:
		print(i, end=' ')
	print(ans[-1])