#include<bits/stdc++.h>
#define endl '\n'
#define fir first
#define sec second
#define ri register
#define pb push_back
#define mp make_pair
#define int long long
#define inf 2147483647
#define Swap(x,y) ((x)^=(y)^=(x)^=(y))
#define reset(x,y) memset((x),(y),sizeof((x)))
#define fastcin ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
/* May all the beauty be blessed. */
using namespace std;
inline int read()
{
	ri int x=0,f=0;ri char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c-'0'),c=getchar();
	return f?-x:x;
}
inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
const int N=2e6+10;
int T,n,m,k,a[N],b[N];
signed main()
{
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	for(T=read();T;--T)
	{
		n=read(),m=read(),k=read();
		if(k==2*n-2)
		{
			for(ri int i=1;i<=2*n;++i)
				a[i]=b[i]=0;
			for(ri int i=1,x;i<=m;++i)
			{
				x=read();
				if(!a[(x+1)/2]) cout<<"1 "<<(x+1)/2<<endl,a[(x+1)/2]=x;
				else if(!b[(x+1)/2])
				{
					cout<<"1 "<<(x+1)/2<<endl;
					if(a[(x+1)/2]!=x) b[(x+1)/2]=x;
						else a[(x+1)/2]=0;
				}
				else if(b[(x+1)/2]==x) cout<<"1 "<<(x+1)/2<<endl,b[(x+1)/2]=0;
				else cout<<"1 "<<n<<"\n2 "<<(x+1)/2<<" "<<n<<endl,a[(x+1)/2]=b[(x+1)/2],b[(x+1)/2]=0;
			}
			continue;
		}
	}
	return 0;
}
//15pts
