# Given an array Arr of size N, swap the Kth element from beginning with Kth element from end.
# User function Template for python3
class Solution:

    def swapKth(self, arr, n, k):
        # code here
        arr[k - 1], arr[n - k] = arr[n - k], arr[k - 1]


# {
#  Driver Code Starts
# Initial Template for Python 3


if __name__ == '__main__':
    tc = int(input())
    while tc > 0:
        n, k = list(map(int, input().strip().split()))
        arr = list(map(int, input().strip().split()))
        ob = Solution()
        ob.swapKth(arr, n, k)
        for x in arr:
            print(x, end=" ")
        print()
        tc -= 1

# } Driver Code Ends
c69b9bc28c62599cb1f3b98d957a8cfc68143ab7
<mask token>

class Solution:
    <mask token>


<mask token>

class Solution:

    def swapKth(self, arr, n, k):
        arr[k - 1], arr[n - k] = arr[n - k], arr[k - 1]


<mask token>

class Solution:

    def swapKth(self, arr, n, k):
        arr[k - 1], arr[n - k] = arr[n - k], arr[k - 1]


if __name__ == '__main__':
    tc = int(input())
    while tc > 0:
        n, k = list(map(int, input().strip().split()))
        arr = list(map(int, input().strip().split()))
        ob = Solution()
        ob.swapKth(arr, n, k)
        for x in arr:
            print(x, end=' ')
        print()
        tc -= 1

# Given an array Arr of size N, swap the Kth element from beginning with Kth element from end.
# User function Template for python3
class Solution:

    def swapKth(self, arr, n, k):
        # code here
        arr[k - 1], arr[n - k] = arr[n - k], arr[k - 1]


# {
#  Driver Code Starts
# Initial Template for Python 3


if __name__ == '__main__':
    tc = int(input())
    while tc > 0:
        n, k = list(map(int, input().strip().split()))
        arr = list(map(int, input().strip().split()))
        ob = Solution()
        ob.swapKth(arr, n, k)
        for x in arr:
            print(x, end=" ")
        print()
        tc -= 1

# } Driver Code Ends