#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(vector<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif
template<typename T> void print(T && x) {cout << x << "\n";}
template<typename T, typename... S> void print(T && x, S&&... y) {cout << x << ' ';print(y...);}

const int Mod=1000000007,Mod2=998244353;
const int MOD=666013;
const int maxn=105;

//i_am_noob
#define wiwihorz  

bool query1(int x, int y){
    print(1,x,y);
    cout << flush;
    int res;
    cin >> res;
    return res;
}

bool query2(int x, vector<int> vec){
    print0(2);
    print0(x);
    print0(sz(vec));
    for(auto i: vec) print0(i);
    cout << endl;
    int res;
    cin >> res;
    return res;
}

int n,pos[maxn];
vector<int> vec,stk;

void orzck(){
    cin >> n;
    vec.clear();
    vec.pb(0);
    rep2(i,1,n){
        int l=0,r=i;
        while(l<r){
            int mid=l+r+1>>1;
            if(query1(vec[mid-1],i)) l=mid;
            else r=mid-1;
        }
        vec.insert(vec.begin()+l,i);
    }
    bug(vec);
    stk.clear();
    stk.pb(0);
    rep2(i,1,n){
        stk.pb(i);
        while(stk.back()){
            vector<int> tmp;
            rep1(j,stk.back()) tmp.pb(vec[j]);
            if(query2(vec[i],tmp)) stk.pop_back();
            else break;
        }
    }
    stk.pb(n);
    rep(sz(stk)-1) rep2(j,stk[i],stk[i+1]) pos[vec[j]]=i;
    print(3);
    rep(n){
        rep1(j,n) cout << (pos[i]<=pos[j]?1:0);
        cout << "\n";
    }
    cout << flush;
    int x;
    cin >> x;
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    /*
    #ifdef i_am_noob
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    freopen("output2.txt","w",stderr);
    #endif
    */
    cout << fixed << setprecision(15);
    int t;
    #ifdef wiwihorz
    cin >> t;
    #else
    t=1;
    #endif
    while(t--) orzck();
    return 0;
}