from random import randint from collections import deque def solve(): n = int(input()) plist = list(map(int, input().split())) deq = deque() deq.append(plist[0]) for i in range(1, n): p = plist[i] if randint(0,1) == 0: deq.appendleft(p) else: deq.append(p) print(0) print(*deq) q = int(input()) while q: q -= 1 solve()