#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int read()
{
	int x=0,f=1;
	char ch = getchar();
	while (ch > '9' || ch < '0')
		{
			if (ch == '-')
				f = -1;
			ch = getchar();
		}
	while (ch <= '9' && ch >= '0')
		{
			x = x*10+ch-'0';
			ch = getchar();
		}
	return x*f;
}
void write(int x)
{
	if (x < 0)
		{
			putchar('-');
			x = -x;
		}
	if (x > 9)
		write(x/10);
	putchar(x%10+'0');
}
int T,n,m,k,type;
int a[2001000];
deque<int> s[310];
int main()
{
	//freopen("meow1.in","r",stdin);
	
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
	
	T = read();
	type = T%10;
	while (T--)
		{
			n = read();
			m = read();
			k = read();
			for (int i=1;i<=n;++i)
				s[i].clear();
			for (int i=1;i<=m;++i)
				a[i] = read();
			/*if (type == 1)
				{*/
					for (int i=1;i<=m;++i)
						{
							//cout<<s[a[i]%(n-1)+1].size()<<endl;
							//cout<<s[a[i]%(n-1)+1].front()<<endl;
							if (s[a[i]%(n-1)+1].size() > 0 && s[a[i]%(n-1)+1].front() == a[i])
								{
									printf("1 %d\n",n);
									printf("2 %d %d\n",a[i]%(n-1)+1,n);
									s[a[i]%(n-1)+1].pop_front();
								}
							else
								{
									printf("1 %d\n",a[i]%(n-1)+1);
									s[a[i]%(n-1)+1].push_back(a[i]);
									if (s[i].size() > 1)
										while (1)
											{
												int x = s[a[i]%(n-1)+1].back();
												s[i].pop_back();
												int y = s[a[i]%(n-1)+1].back();
												s[i].pop_back();
												if (x != y)
													{
														s[i].push_back(y);
														s[i].push_back(x);
														break;
													}
											}
								}
						}
				//}
			/*else if (type == 2)
				{
					
				}*/
		}
	return 0;
}
/*
1
2 4 2
1 2 1 2
*/
