for _ in range(int(input())):
    n = int(input())
    a = list(map(int,input().split()))
    m = a.index(max(a))
    if(n==1):
        print(*a)
    elif(a==2):
        print(a[1],a[0])
    else:
        if(a[0]==a[m]):
            a[1],a[2] = a[2],a[1]
        a[0],a[m] = a[m],a[0]
        print(*a)
    