#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

std::vector<std::vector<int>> nx_init(const std::string &s, const char basis = 'a', const int sigma = 26) {
  int n = s.size();
  std::vector<std::vector<int>> nx(n, std::vector<int>(sigma, n));
  nx[n - 1][s[n - 1] - basis] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    for (int j = 0; j < sigma; ++j) nx[i][j] = nx[i + 1][j];
    nx[i][s[i] - basis] = i;
  }
  return nx;
}

void solve() {
  int n; cin >> n;
  string s[3]; REP(i, 3) cin >> s[i];
  vector<vector<int>> nx[3];
  REP(i, 3) nx[i] = nx_init(s[i] + s[i], '0', 2);
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = string(n, '0' + i) + to_string(j) + string(n, '0' + l);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = to_string(j) + string(n, '0' + i) + string(n, '0' + l);
    swap(ans[n - 1], ans[n]);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  REP(i, 2) REP(j, 2) REP(l, 2) {
    string ans = string(n, '0' + i) + string(n, '0' + l) + to_string(j);
    swap(ans[n - 1], ans[n]);
    bool valid = true;
    REP(x, 3) {
      bool ok = true;
      int pos = 0;
      for (char c : ans) {
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        pos = nx[x][pos][c - '0'];
        if (pos >= n * 4) {
          ok = false;
          break;
        }
        ++pos;
      }
      valid &= ok;
    }
    if (valid) {
      cout << ans << '\n';
      return;
    }
  }
  // cout << n << endl;
  // REP(i, 3) cout << s[i] << endl;
  assert(false);
}

int main() {
  int t; cin >> t;
  while (t--) solve();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int,int> > x,y;
vector<int> ans;
map<pair<int,int>,int > ma;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int u,v;
        cin>>u>>v;
        x.push_back({u,i});
        y.push_back({v,i});
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int a=x.size();
    int b=y.size();
    for(int i=a-1;i>=a-3;i--)
    {
        ans.push_back(abs(x[0].first-x[i].first));
        ma[{x[0].second,x[i].second}]=1;
    }
    for(int i=0;i<3;i++)
    {
        if(ma[{x[i].second,x[x.size()-1].second}]==0)
            {
                ans.push_back(abs(x[i].first-x[x.size()-1].first));
                ma[{x[i].second,x[x.size()-1].second}]=1;
            }
    }
    for(int i=b-1;i>=b-3;i--)
    {
        if(ma[{y[0].second,y[i].second}]==0)
            {
                ans.push_back(abs(y[0].first-y[i].first));
                ma[{y[0].second,y[i].second}]=1;
            }
    }
    for(int i=0;i<3;i++)
    {
        if(ma[{y[i].second,y[x.size()-1].second}]==0)
            {
                ans.push_back(abs(y[i].first-y[x.size()-1].first));
                ma[{x[i].second,x[x.size()-1].second}]=1;
            }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[ans.size()-2];
}
