#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

const int MAXN = 110;
const int INF = 1000000010;
const lli INFLL = 1000000000000000010LL;

int n;

int rootSCC[MAXN];
int topoSort[MAXN];

bool reach[MAXN][MAXN];

bool cmp(int a, int b)
{
	cout << "1 " << a << " " << b << endl;

	int ans;
	cin >> ans;

	return ans;
}

bool hasEdge(int node, int L, int R)
{
	if( L > R ) return false;

	int sizeInterval = R - L + 1;
	cout << "2 " << node << " " << sizeInterval << " ";

	for(int i = L ; i <= R ; i++)
		cout << topoSort[i] << " ";

	cout << endl;

	int ans;
	cin >> ans;

	return ans;
}

void solveTestCase(int testCase)
{
	scanf("%d",&n);

	iota( topoSort , topoSort + n , 0 );
	stable_sort( topoSort , topoSort + n , cmp );

	memset( reach , false , sizeof(reach) );
	memset( rootSCC , -1 , sizeof(rootSCC) );

	int L = n - 1;

	for(int i = n - 1 ; i >= 0 ; i--)
	{
		L = min( L , i );

		while( hasEdge( topoSort[i] , 0 , L - 1 ) )
			L--;

		if( i == L ) // Is root
		{
			for(int j = i ; j < n && rootSCC[j] == -1 ; j++)
				rootSCC[j] = i;
		}
	}

	for(int i = 0 ; i < n ; i++)
		for(int j = rootSCC[i] ; j < n ; j++)
			reach[ topoSort[i] ][ topoSort[j] ] = true;

	cout << "3" << endl;

	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < n ; j++)
		{
			if( reach[i][j] ) cout << "1";
			else cout << "0";
		}

		cout << endl;
	}

	int result;
	scanf("%d",&result);

	if( result == -1 )
		exit(0);
}

int main()
{
	int qtdTestCases = 1;
	scanf("%d",&qtdTestCases);

	for(int testCase = 1 ; testCase <= qtdTestCases ; testCase++)
		solveTestCase( testCase );
}