human
A permutation of length n 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).

Let p be any permutation of length n. We define the fingerprint F(p) of p as the sorted array of sums of adjacent elements in p. More formally,

$$$F(p)=sort([p_1+p_2,p_2+p_3,…,p_{n-1}+p_n]).$$$

For example, if n=4 and p=[1,4,2,3], then the fingerprint is given by F(p)=sort([1+4,4+2,2+3])=sort([5,6,5])=[5,5,6].

You are given a permutation p of length n. Your task is to find a different permutation p' with the same fingerprint. Two permutations p and p' are considered different if there is some index i such that p_i ≠ p'_i.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 668). Description of the test cases follows.

The first line of each test case contains a single integer n (2≤ n≤ 100) — the length of the permutation.

The second line of each test case contains n integers p_1,…,p_n (1≤ p_i≤ n). It is guaranteed that p is a permutation.

Output

For each test case, output n integers p'_1,…, p'_n — a permutation such that p'≠ p and F(p')=F(p).

We can prove that for every permutation satisfying the input constraints, a solution exists.

If there are multiple solutions, you may output any.

Example

Input

3
2
1 2
6
2 1 6 5 4 3
5
2 4 3 1 5

Output

2 1
1 2 5 6 3 4
3 1 5 2 4

Note

In the first test case, F(p)=sort([1+2])=[3].

And F(p')=sort([2+1])=[3].

In the second test case, F(p)=sort([2+1,1+6,6+5,5+4,4+3])=sort([3,7,11,9,7])=[3,7,7,9,11].

And F(p')=sort([1+2,2+5,5+6,6+3,3+4])=sort([3,7,11,9,7])=[3,7,7,9,11].

In the third test case, F(p)=sort([2+4,4+3,3+1,1+5])=sort([6,7,4,6])=[4,6,6,7].

And F(p')=sort([3+1,1+5,5+2,2+4])=sort([4,6,7,6])=[4,6,6,7].
impor
assistant
#Here is Python program to find a different permutation p' with the same fingerprint.
t sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt,gcd

# def time_t():
#     print("Current date and time: " , datetime.datetime.now())
#     print("Current year: ", datetime.date.today().strftime("%Y"))
#     print("Month of year: ", datetime.date.today().strftime("%B"))
#     print("Week number of the year: ", datetime.date.today().strftime("%W"))
#     print("Weekday of the week: ", datetime.date.today().strftime("%w"))
#     print("Day of year: ", datetime.date.today().strftime("%j"))
#     print("Day of the month : ", datetime.date.today().strftime("%d"))
#     print("Day of week: ", datetime.date.today().strftime("%A"))

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

def sip(): return sys.stdin.readline()

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

def mips(): return map(str,sys.stdin.readline().split())

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

def matip(n,m):
    lst=[]
    for i in range(n):
        arr = lip()
        lst.append(arr)
    return lst

def factors(n): # find the factors of a number
    return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

def minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps
    jumps = [0 for i in range(n)]
    if (n == 0) or (arr[0] == 0):
        return float('inf')
    jumps[0] = 0
    for i in range(1, n):
        jumps[i] = float('inf')
        for j in range(i):
            if (i <= j + arr[j]) and (jumps[j] != float('inf')):
                jumps[i] = min(jumps[i], jumps[j] + 1)
                break
    return jumps[n-1]

def dic(arr): # converting list into dict of count
    return Counter(arr)

def check_prime(n):
    if n<2:
        return False
    for i in range(2,int(n**(0.5))+1,2):
        if n%i==0:
            return False
    return True 

# --------------------------------------------------------- #
# sys.stdin = open('input.txt','r')
# sys.stdout = open('output.txt','w')
#...