Swap kth node
/*
http://ideone.com/IecjJp
http://www.geeksforgeeks.org/swap-kth-node-from-beginning-with-kth-node-from-end-in-a-linked-list/
http://www.practice.geeksforgeeks.org/problem-page.php?pid=535
*/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int t, n, k;
cin >> t;
while(t--){
cin >> n >> k;
if(n < k){
cout << k << " is bigger than " << n <<endl;
return 0;
}
int a[1001];
for(int i=0; i<n; i++)
cin >> a[i];
int temp = a[k-1];
a[k-1] = a[n-k];
a[n-k] = temp;
for(int i=0; i<n; i++){
cout << a[i];
cout << ((i==n-1) ? "\n" : " ");
}
}
return 0;
}