#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<climits>
using namespace std;

int main()
{
	int l = 0, n = 0, k = 0, t = 0;
	vector<int> d1, d2, d;
	cin >> l;
	for (int i = 1; i <= l; i++)//一共L组
	{
		cin >> n >> k;//一手n张牌,洗k次
		for (int j = 0; j < n; j++)
		{
			cin >> t;
			d1.push_back(t);
		}
		for (int j = 0; j < n; j++)
		{
			cin >> t;
			d2.push_back(t);
		}
		//成功分成左右手
		//change()*k;开始洗牌
		for (int a = 1; a <= k; a++)
		{
			for (int b = 0; b < n; b++)
			{
				d.push_back(d2[n - b - 1]);
				d.push_back(d1[n - b - 1]);
			}
			d1.clear();
			d2.clear();
			reverse(d.begin(), d.end());
		  	//意外发现只要按题目说的尾插,再反转正好是洗一次牌
			for (int j = 0; j < n; j++)
			{
				d1.push_back(d[j]);
			}
			for (int j = n; j < 2 * n; j++)
			{
				d2.push_back(d[j]);
			}
		  	//再拆分为左右手
			if (a != k)
			{
				d.clear();
			  //不留记忆
			}
		}
	  //跳出洗牌,准备输出
		for (auto c : d)
		{
			cout << c << " ";
		}
		cout << endl;
		d.clear();
		d1.clear();
		d2.clear();
	  //不要干扰第二组洗牌
	}
	return 0;
}