//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define Dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int T;

bool check(const string& S, const string& T) {
    //S > T;
    int N = S.size();
    int now = 0;
    for (int i = 0; i < T.size(); i++) {
        if (now >= N)
            return false;
        while (T[i] != S[now]) {
            now++;
            if (now >= N)
                return false;
        }
        now++;
    }
    return true;
}

void solve() {
    while (T--) {
        int N;
        cin >> N;
        string S[3];
        cin >> S[0] >> S[1] >> S[2];
        vector<string> T;
        for (int a = 0; a < 2; a++) {
            for (int b = 0; b < 2; b++) {
                string A, B;
                for (int i = 0; i < N; i++) {
                    A += (char)('0' + a);
                    B += (char)('0' + b);
                }
                T.emplace_back('0' + A + B);
                T.emplace_back('1' + A + B);
                T.emplace_back(A + '0' + B);
                T.emplace_back(A + '1' + B);
                T.emplace_back(A + B + '0');
                T.emplace_back(A + B + '1');
            }
        }
        for (int i = 0; i < 3; i++) {
            S[i] += S[i];
        }
        string ans;
        for (auto& s : T) {
            if (check(S[0], s) && check(S[1], s) && check(S[2], s)) {
                ans = s;
                break;
            }
        }
        cout << ans << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> T;

    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

vector<vector<ll> > vertexes(200, vector<ll>(4));
vector<ll> rlist(200);

bool check_no_overlap(ll label, ll n){
    ll ax1 = vertexes.at(label).at(0), ay1 = vertexes.at(label).at(1), ax2 = vertexes.at(label).at(2), ay2 = vertexes.at(label).at(3);
    REP(i,n){
        if (i==label){continue;}
        ll bx1 = vertexes.at(i).at(0), by1 = vertexes.at(i).at(1), bx2 = vertexes.at(i).at(2), by2 = vertexes.at(i).at(3);
        if ((max(ay1,by1)<=min(ay2,by2)) && (max(ax1,bx1)<=min(ax2,bx2))){return false;}
    }
    return true;
}

bool meet(ll x,ll n){
    if (check_no_overlap(x,n) && (0 <= vertexes.at(x).at(0) && 0 <= vertexes.at(x).at(1) && vertexes.at(x).at(2) < 10000 && vertexes.at(x).at(3) < 10000)){
        return true;
    }else{
        return false;
    }
}


int main() {
    
    ll n;
    cin >> n;

    
    clock_t start = clock();

    REP(i,n){
        ll x,y,r;
        cin >> x >> y >> r;
        vertexes.at(i).at(0) = x; vertexes.at(i).at(1) = y; vertexes.at(i).at(2) = x+1; vertexes.at(i).at(3) = y+1;
        rlist.at(i) = r;
    }

    while (static_cast<double> (clock()-start) / CLOCKS_PER_SEC * 1.0 < 4.8){
        ll label = rand() % n;
        ll rl = rlist.at(label);

        double t = static_cast<double> (clock()-start) / CLOCKS_PER_SEC * 1.0;
        ll w = (ll) (-13*t + 53);
        if (t >= 4){w = 1;}
        

        ll pre_sl = (vertexes.at(label).at(2)-vertexes.at(label).at(0))*(vertexes.at(label).at(3)-vertexes.at(label).at(1));
        double pre_score = 1-(1-((double) min(rl,pre_sl))/max(rl,pre_sl))*(1-((double) min(rl,pre_sl))/max(rl,pre_sl));

        REP(dir,4){
            
            if (dir<2){vertexes.at(label).at(dir) -= w;}
            else{vertexes.at(label).at(dir)+=w;}

            ll sl = (vertexes.at(label).at(2)-vertexes.at(label).at(0))*(vertexes.at(label).at(3)-vertexes.at(label).at(1));
            double score =  1-(1-((double) min(rl,sl))/max(rl,sl))*(1-((double) min(rl,sl))/max(rl,sl));

            if (meet(label,n) && score > pre_score) {pre_score=score;}
            else{
                if (dir<2){vertexes.at(label).at(dir) += w;}
                else{vertexes.at(label).at(dir)-=w;}
            }
        }
    }

    REP(i,n){
        cout << vertexes.at(i).at(0) << " " << vertexes.at(i).at(1) << " " << vertexes.at(i).at(2) << " " << vertexes.at(i).at(3) << endl; 
    }
}