#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
//#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 100;
int n;
int a[mxn], f[mxn], v[mxn];

bool qr1(int x, int y){
	int ret;
	cout << 1 << " " << x << " " << y << endl;
	cin >> ret;
	return ret;
}

bool qr2(int x, int y){
	int ret;
	cout << 2 << " " << a[x] << " " << y;
	for(int i = 0; i < y; i++) cout << " " << a[i];
	cout << endl;
	cin >> ret;
	return ret;
}

void dfs(int c){
	v[a[c]] = 1;
	if(c < n - 1 && !v[a[c + 1]]) dfs(c + 1);
	if(~f[c] && !v[a[f[c]]]) dfs(f[c]);
}

void answer(){
	cin >> n;
	
	for(int i = 0; i < n; i++) a[i] = i, f[i] = -1;
	
	stable_sort(a, a + n, [&](int x, int y){ return qr1(x, y);});
	
	for(int i = n - 1, j = n - 1; ~i; i--){
		bool t = 0;
		while(j && (j > i || qr2(i, j))) t |= (--j) < i;
		if(t) f[i] = j;
	}
	
	cout << 3 << endl;
	for(int i = 0; i < n; i++){
		memset(v, 0, sizeof(v));
		dfs(find(a, a + n, i) - a);
		for(int i = 0; i < n; i++) cout << v[i];
		cout << endl;
	}
	
	int ret;
	cin >> ret;
	if(!~ret) exit(0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

	return 0;
}