#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 105;
 
int n;
vector<int> a;
bool g[N][N];
 
bool query1(int x, int y)
{
    printf("1 %d %d\n", x, y);
    fflush(stdout);
    scanf("%d", &x);
    return x;
}
 
int query2(int x, const vector<pair<int, int>> &v)
{
    printf("2 %d %d", x, v.back().second + 1);
    for (auto [from, to] : v)
        for (int i = from; i <= to; ++i)
            printf(" %d", a[i]);
    putchar('\n');
    fflush(stdout);
    scanf("%d", &x);
    return x;
}
 
int main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        a = {0};
        for (int i = 1; i < n; ++i)
            a.insert(lower_bound(a.begin(), a.end(), i, query1), i);
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                g[i][j] = i == j;
        for (int i = 0; i + 1 < n; ++i)
            g[a[i]][a[i + 1]] = 1;
        vector<pair<int, int>> stk;
        for (int i = 0; i < n; ++i)
        {
            while (!stk.empty() && query2(a[i], stk))
            {
                g[a[i]][a[stk.back().first]] = 1;
                stk.pop_back();
            }
            stk.emplace_back(stk.empty() ? 0 : stk.back().second + 1, i);
        }
        for (int k = 0; k < n; ++k)
            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    g[i][j] |= g[i][k] & g[k][j];
        puts("3");
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
                putchar(g[i][j] ? '1' : '0');
            putchar('\n');
        }
        fflush(stdout);
        scanf("%*d");
    }
    return 0;
}