#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int n, t;
int ff[105] = {0};
int tmp[105];
char anss[105][105];
//char ss[10005] = "011100111101001011100000100111000000001100010100111000000000100000000101000000000100111101111101101011100111100111101001001100000000000000000000100000100100000000000100000000110000000000100011100111000000000100111111111101001011100011100111100000000100111101111111001011100111111111111101111111011100111101000000100111111111111101011101011101111101001001100001100111101001000100000000000000000000000111111111111101111101111111111111101011100";

bool query(int a, int b)
{
	cout << 1 << " " << a << " " << b << '\n';
	cout.flush();
	int res;
	cin >> res;
	if (res == -1)
	{
		exit(0);
	}
	return !!res;
//	return ss[a * n + b] == '1';
}

bool query2(int a, int b, int c)
{
	cout << 2 << " " << ff[c] << " " << b - a;
	for (int i = a; i < b; ++i)
	{
		cout << " " << ff[i];
	}
	cout << '\n';
	cout.flush();
	int res;
	cin >> res;
	if (res == -1)
	{
		exit(0);
	}
	return !!res;
//	for (int i = a; i < b; ++i)
//	{
//		if (ss[ff[c] * n + ff[i]] == '1')
//		{
//			return true;
//		}
//	}
//	return false;
}

void ssort(int l, int r)
{
	if (l == r)
	{
		return;
	}
	int mid = l + (r - l) / 2;
	ssort(l, mid);
	ssort(mid + 1, r);
	int p = l, ll = l, rr = mid + 1;
	while (ll <= mid && rr <= r)
	{
		bool bk = query(ff[ll], ff[rr]);
		if (bk)
		{
			tmp[p++] = ff[ll++];
		}
		else
		{
			tmp[p++] = ff[rr++];
		}
	}
	while (ll <= mid)
	{
		tmp[p++] = ff[ll++];
	}
	while (rr <= r)
	{
		tmp[p++] = ff[rr++];
	}
	for (int i = l; i <= r; ++i)
	{
		ff[i] = tmp[i];
	}
}

int main()
{
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; ++i)
		{
			ff[i] = i;
		}
		ssort(0, n - 1);
		int l = n - 1, r = n - 1;
		for (int i = n - 1; i >= 0; --i)
		{
			if (l > i)
			{
				for (int o = i + 1; o <= r; ++o)
				{
					for (int p = 0; p <= i; ++p)
					{
						anss[ff[o]][ff[p]] = '0';
					}
					for (int p = i + 1; p < n; ++p)
					{
						anss[ff[o]][ff[p]] = '1';
					}
				}
				r = i;
				--l;
			}
			while (l > 0 && query2(0, l, i))
			{
				--l;
			}
		}
		for (int o = 0; o <= r; ++o)
		{
			for (int p = 0; p < n; ++p)
			{
				anss[ff[o]][ff[p]] = '1';
			}
		}
		cout << "3\n";
		cout.flush();
		for (int i = 0; i < n; ++i)
		{
			anss[i][n] = 0;
			cout << anss[i] << '\n';
			cout.flush();
		}
		cin >> l;
		if (l == -1)
		{
			exit(0);
		}
	}
	return 0;
}
