You are given a permutation of length $n$. Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2, 3, 1, 5, 4]$ is a permutation, but $[1, 2, 2]$ is not a permutation ($2$ appears twice in the array) and $[1, 3, 4]$ is also not a permutation ($n=3$ but there is $4$ in the array).

You can perform at most $n-1$ operations with the given permutation (it is possible that you don't perform any operations at all). The $i$-th operation allows you to swap elements of the given permutation on positions $i$ and $i+1$. Each operation can be performed at most once. The operations can be performed in arbitrary order.

Your task is to find the lexicographically minimum possible permutation obtained by performing some of the given operations in some order.

You can see the definition of the lexicographical order in the notes section.

You have to answer $q$ independent test cases.

For example, let's consider the permutation $[5, 4, 1, 3, 2]$. The minimum possible permutation we can obtain is $[1, 5, 2, 4, 3]$ and we can do it in the following way:

  perform the second operation (swap the second and the third elements) and obtain the permutation $[5, 1, 4, 3, 2]$;  perform the fourth operation (swap the fourth and the fifth elements) and obtain the permutation $[5, 1, 4, 2, 3]$;  perform the third operation (swap the third and the fourth elements) and obtain the permutation $[5, 1, 2, 4, 3]$.  perform the first operation (swap the first and the second elements) and obtain the permutation $[1, 5, 2, 4, 3]$; 

Another example is $[1, 2, 4, 3]$. The minimum possible permutation we can obtain is $[1, 2, 3, 4]$ by performing the third operation (swap the third and the fourth elements).


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 100$) — the number of test cases. Then $q$ test cases follow.

The first line of the test case contains one integer $n$ ($1 \le n \le 100$) — the number of elements in the permutation.

The second line of the test case contains $n$ distinct integers from $1$ to $n$ — the given permutation.


-----Output-----

For each test case, print the answer on it — the lexicograhically minimum possible permutation obtained by performing some of the given operations in some order.


-----Example-----
Input
4
5
5 4 1 3 2
4
1 2 4 3
1
1
4
4 3 2 1

Output
1 5 2 4 3 
1 2 3 4 
1 
1 4 3 2 



-----Note-----

Recall that the permutation $p$ of length $n$ is lexicographically less than the permutation $q$ of length $n$ if there is such index $i \le n$ that for all $j$ from $1$ to $i - 1$ the condition $p_j = q_j$ is satisfied, and $p_i < q_i$. For example:

  $p = [1, 3, 5, 2, 4]$ is less than $q = [1, 3, 5, 4, 2]$ (such $i=4$ exists, that $p_i < q_i$ and for each $j < i$ holds $p_j = q_j$),  $p = [1, 2]$ is less than $q = [2, 1]$ (such $i=1$ exists, that $p_i < q_i$ and for each $j < i$ holds $p_j = q_j$).

Difficulty: introductory

Starter code:

Solutions:
q = int(input())
for qi in range(q):
    n = int(input())
    a = list(map(int, input().split()))
    used = [False] * n
    for t in range(n):
        for i in range(len(a) - 1, 0, -1):
            if used[i]:
                continue
            if a[i] < a[i - 1]:
                a[i], a[i - 1] = a[i - 1], a[i]
                used[i] = True
    print(' '.join(str(x) for x in a))

q=int(input())
for t in range(q):
    n=int(input())
    a=list(map(int,input().split()))
    used=[0]*n
    for i in range(1,n+1):
        ind=a.index(i)
        while ind>0 and used[ind-1]==0 and a[ind-1]>i:
            s=a[ind-1]
            a[ind]=s
            a[ind-1]=i
            used[ind-1]=1
            ind-=1
    print(*a)


q=int(input())
for i in range(q):
    w=int(input())
    e=list(map(int,input().split()))
    r=[1]*w
    for k in range(1,w+1):
        t=e.index(k)
        while t>0 and r[t-1] and e[t]<e[t-1]:
            if r[t-1]:
                e[t-1],e[t]=e[t],e[t-1]
                r[t-1]=0
            t-=1
    print(*e)

import sys
input = sys.stdin.readline

q=int(input())

def sortper(begin):
    x=A.index(min(A[begin:]))

    return x,A[:begin]+[A[x]]+A[begin:x]+A[x+1:]
    

for testcases in range(q):
    n=int(input())
    A=list(map(int,input().split()))

    begin=0

    while begin<n-1:
        nbegin,A=sortper(begin)

        if begin==nbegin:
            begin+=1
        else:
            begin=nbegin

        #print(begin," ",*A)
    print(*A)

    


t=int(input())
for tt in range(t):
	n=int(input())
	arr=list(map(int,input().split()))
	visited=[0]*(n)
	index=[0]*(n+1)
	for i in range(1,n+1):
		index[i]=arr.index(i)
	# while 1:
	for i in range(1,n+1):
		for j in range(index[i],0,-1):
			if visited[j]==0 and arr[j-1]>arr[j]:
				temp=arr[j]
				arr[j]=arr[j-1]
				arr[j-1]=temp
				visited[j]+=1
				# flag=True
	for i in arr:
		print(i,end=" ")
	print()

for _ in range(int(input())):
    n=int(input())
    l=[int(i) for i in input().split()]
    k=n-1 
    i=0 
    while i<n:
        mini=l[i]
        ind=-1 
        j=i+1 
        while j<min(n,i+k+1): 
            if l[j]<mini:
                mini=l[j]
                ind=j
            j+=1 
        if ind==-1:
            i+=1 ;
            continue 
        #print(ind)
        temp=ind 
        while ind>i and k!=0:
            #print('ef')
            l[ind],l[ind-1]=l[ind-1],l[ind]
           # print(l)
            ind-=1 
            k-=1 
        i=temp 
    print(*l)

import io, sys, atexit, os
import math as ma
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)


mm = 1000000007


def solve ():
	t = nu()
	for tt in range (t):
		n=nu()
		a=li()
		b=[0]*n
		for i in range(1,n+1):
			ind=-1
			for j in range(n):
				if(a[j]==i):
					ind=j
					break
			while(ind>0):
				oz=ind-1
				if(b[oz]==1):
					break
				if(a[oz]<a[ind]):
					break
				b[oz]=1
				a[oz],a[ind]=a[ind],a[oz]
				ind-=1
		print(*a)




def __starting_point():
	solve ()
__starting_point()

from sys import stdin

for _ in range(int(stdin.readline())):

	n = int(stdin.readline())
	arr = [int(x) for x in stdin.readline().split()]

	flags = [0]*n

	any = True

	while any==True:

		any = False

		for i in range(n-1,0,-1):

			if arr[i-1]>arr[i] and flags[i-1]==0:
					any = True
					flags[i-1] = 1
					arr[i-1],arr[i] = arr[i],arr[i-1]

	for i in arr: print(i,end=" ")
	print()

for _ in range(int(input())):
    n = int(input())
    arr = list(map(int, input().split()))
    brr = [0]*(n-1)

    for i in range(n-2,-1,-1):
        if arr[i]>arr[i+1]:
            arr[i], arr[i+1] = arr[i+1], arr[i]
            brr[i] = 1

    for i in range(n-1):
        if arr[i]>arr[i+1] and brr[i]==0:
            arr[i], arr[i+1] = arr[i+1], arr[i]
            brr[i] = 1
    print(*arr)            
            


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int,minp().split()))

def solve():
	n = mint()
	a = list(mints())
	b = [True]*n
	for i in range(n-1):
		j = i + 1
		z = (a[i],i)
		while j < n and b[j-1]:
			z = min(z, (a[j], j))
			j += 1
		if z[0] < a[i]:
			j = z[1] - 1
			while j >= i:
				a[j], a[j+1] = a[j+1], a[j]
				b[j] = False
				j -= 1
	print(*a)


for i in range(mint()):
	solve()


q = int(input())
for __ in [0]*q:
    n = int(input())
    a = list(map(int,input().split()))
    idx = [-1]*(n+1)
    for i,e in enumerate(a):
        idx[e] = i

    res = []
    k = -1
    for i,e in enumerate(idx):
        if e == -1:
           continue
        if e > k:
            res.append(i)
            if i != 1:
                if res[-1] < res[-2]:
                    res[-1],res[-2] = res[-2],res[-1]
            for i in range(k+1,e):
                res.append(a[i])
            k = e
    for e in res:
        if e != res[-1]:
            print(e,end = ' ')
        else:
            print(e)

import sys


def main():
    for _ in range(int(input())):
        n = int(input())
        arr = get_array()
        d = {}

        def solve(i):
            idx = 0
            for j in range(n):
                if arr[j] == i:
                    idx = j
                    break
            p = idx
            for j in range(idx - 1, -1, -1):
                if p in d:
                    break
                if arr[j] < arr[p]:
                    break
                arr[p], arr[j] = arr[j], arr[p]
                d[p] = 1
                p -= 1

        for i in range(1, n + 1):
            solve(i)
        print(*arr)


input = lambda: sys.stdin.readline().strip()
get_ints = lambda: list(map(int, input().split()))
get_array = lambda: list(map(int, input().split()))
main()


ct = int(input())
for c in range(ct):
    n = int(input())
    li = [int(i) for i in input().split()]

    op = [0 for i in range(n)]
    for i in range(1, n+1):
        pos = li.index(i)
        for j in range(pos-1, -1, -1):
            if op[j] == 0 and li[j] > li[j+1]:
                op[j] = 1
                li[j], li[j+1] = li[j+1], li[j]
            else:
                break
    # print(op)
    print(*li)


for _ in range(int(input())):
    n=int(input())
    l1=list(map(int,input().split()))
    stack=[]
    marked={}
    i=0
    j=1
    result=[]
    while j<=n:
        if j not in marked:
            stack=[]
            result.append(j)
            while l1[i]!=j:
                marked[l1[i]]=1
                stack.append(l1[i])
                i+=1
            marked[j]=1

            if stack:
                l1[i]=stack[-1]
                del marked[stack[-1]]
                result.extend(stack[:len(stack)-1])
            else :
                i+=1
        j+=1
    print(*result,sep=" ")
            

q=int(input())
while(q):
    q-=1
    n=int(input())
    *a,=map(int,input().split())
    u=[False for i in range(n+1)]
    u[0]=True
    for i in range(1,n+1):
        for j in range(n):
            if a[j]==i:
                x=j
                while not u[x] and a[x]<a[x-1]:
                    a[x],a[x-1]=a[x-1],a[x]
                    u[x]=True
                    x -= 1
    print(*a)

import sys
input=sys.stdin.readline
y=int(input())
for i in range(y):
	n=int(input())
	arr=list(map(int,input().split())) 
	a=0
	visited=[0]*n
	
	for j in range(n):
		for k in range(n-1,0,-1):
			if(visited[k-1]==0 and arr[k-1]>arr[k]):
				visited[k-1]=1
				temp=arr[k-1]
				arr[k-1]=arr[k]
				arr[k]=temp

	s=""
	for j in arr:
		s=s+str(j)+" "
	s=s[:-1]
	print(s)

def doit(lst):
   # print(lst)
    n = len(lst)
    if(n<=1):
        return(lst)
    index = lst.index(min(lst))
    if(index==0):
        l = doit(lst[1:])
        return([lst[0]]+l)
    temp = [lst[index-1]]+lst[index+1:]
    
    return([lst[index]] + lst[:index-1]+doit(temp))

t = int(input())
for _ in range(t):
    n = int(input())
    lst = list(map(int, input().split()))
    print(*doit(lst))
    
    


def f(a, l):
    m = a[l]
    mi = l
    for i in range(l, len(a)):
        if a[i] < m:
            m = a[i]
            mi = i

    for i in range(mi, l, -1):
        a[i] = a[i - 1]
    a[l] = m
    return mi if mi != l else mi + 1


for _ in range(int(input())):
    n = int(input())
    a = [int(x) for x in input().split()]
    mi = 0
    while mi < n:
        mi = f(a, mi)
    print(*a)


q = int(input())
res = []
for _ in range(q):
    n = int(input())
    a = list(map(int, input().split()))
    l = 0
    for m in range(1, n+1):
        i = a.index(m)
        if i <= l:
            continue
        for j in range(i-1, l-1, -1):
            if a[j] < a[j+1]:
                break
            a[j], a[j+1] = a[j+1], a[j]
        l = i

    res.append(' '.join(map(str, a)))

print(*res, sep='\n')

t = int(input())
answer = []

def mini(arr):
    minimum = arr[0]
    index = 0
    for i in range (1, len(arr)):
        if minimum > arr[i]:
            minimum = arr[i]
            index = i
    return index

for i in range (t):
    n = int(input())
    p = list(map(int,input().split()))
    ans = []
    
    while len(p) > 1:
        index = mini(p)
        ans.append(p[index])
        for k in range (index - 1):
            ans.append(p[k])
        p = p[index-1 : index] + p[index + 1:]
    if len(p) == 1:
        ans.append(p[0])
    answer.append(ans)
for i in range (t):
    print (*answer[i], sep = " ")

t = int(input())
while(t > 0):
    t -= 1
    n = int(input())
    arr = list(map(int, input().split()))
    bol = [True for i in range(n)]
    flag = True
    while(flag):
        flag = False
        for i in range(n-1):
            if(arr[n-i-1] < arr[n-i-2] and bol[n-i-1]):
                bol[n-i-1] = False
                tmp = arr[n-i-1]
                arr[n-i-1] = arr[n-i-2]
                arr[n-i-2] = tmp
                flag = True
    for x in range(n):
        if(x > 0):print(" ",end="")
        print(arr[x],end="")
    print()

def optimize(arr, idx):
    if idx >= len(arr):
        return
    min_idx = -1
    min_val = 1e9
    for i in range(idx, len(arr)):
        if arr[i] < min_val:
            min_val = arr[i]
            min_idx = i

    

    for i in range(min_idx-1, idx-1,-1):
        tmp=arr[i]
        arr[i]=arr[i+1]
        arr[i+1]=tmp
    
    if min_idx == idx:
        min_idx += 1        
    optimize(arr,min_idx)

q=int(input())
for t in range(q):
    n=int(input())
    a=[int(x) for x in input().split()]
    optimize(a,0)
    print(*a)


for _ in range(int(input())):
    n = int(input())
    *a, = map(int, input().split())
    ans, i = [], 0
    while a:
        m = min(a)
        x = a.index(m)
        ans.append(m)
        if x == 0:
            a.remove(m)
            continue
        ans += a[:x - 1]
        a = a[x - 1:]
        if m in a:
            a.remove(m)
        
    print(*ans)