#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pre(i,a,b) for(int i=a;i>=b;i--)
#define N 105
using namespace std;
int n,u[N],fa[N],mat[N];
bool get(int x,int y){
	cout<<"1 "<<x-1<<" "<<y-1<<endl;
	int op;cin>>op;return op;
}
bool ask(int x,int l,int r){
	cout<<"2 "<<u[x]-1<<" "<<r-l+1<<" ";
	rep(i,l,r)cout<<u[i]-1<<" ";
	cout<<endl;int op;cin>>op;return op;
}
void solve(){
	memset(fa,0,sizeof(fa));
	memset(u,0,sizeof(u));
	memset(mat,0,sizeof(mat));
	cin>>n;
	u[1]=1;fa[1]=1;
	int tot=0;
	rep(i,2,n){
		int l=0,r=i;
		while(l+1<r){
			int mid=(l+r)>>1;
			int cur=get(u[mid],i);
			tot++;
			if(cur)l=mid;else r=mid;
		}
		pre(j,i-1,r)u[j+1]=u[j];
		u[l+1]=i;
	}
	int cur=n;
	pre(i,n,2){
		cur=min(cur,i);
		while(cur>1&&ask(i,1,cur-1))cur--;
		fa[i]=cur;
	}
	rep(i,1,n)rep(j,fa[i],i)fa[i]=min(fa[i],fa[j]);
	rep(i,1,n)mat[u[i]]=i;
	cout<<"3 "<<endl;
	rep(i,1,n){
		rep(j,1,n)if(fa[mat[i]]==fa[mat[j]])putchar('1');
		else if(mat[i]<mat[j])putchar('1');else putchar('0');
		cout<<endl;
	}int op;cin>>op;
}
int main(){
	int T;scanf("%d",&T);
	while(T--)solve();
	return 0;
}