from sys import stdin
from random import shuffle
def reader():
for x in stdin.read().split(): yield int(x)
next = reader().next
T = next()
print T
for t in range(T):
N = next()
print N
A = []
for n in range(N): A.append( next() )
while A==sorted(A) or A[::-1]==sorted(A): shuffle(A)
for x in A: print x