#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vi (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define sz(x) int(x.size())
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}



int main(){
  cii(t);

  V<ss> ans;

  while(t--){
    cii(n);
    vvi v(2,vi(2,0));
    
    V<ss> s(3);
    rep(i,0,3)ci(s[i]);

    rep(i,0,3){
      int fr=s[i][0]-'0';
      int ba=s[i][n*2-1]-'0';

      v[ba][fr]=1;
    }

    ss now;
    ss s0,s1;
    rep(i,0,n){
      s0+="0";
      s1+="1";
    }

    if(v[0][0]==0){
      now=s0+"1"+s0;
    }
    else {
      if(v[1][1]==0){
        now=s1+"0"+s1;
      }
      else {
        if(v[0][1]==0)now=s0+s1+"0";   
        else now=s1+s0+"1";
      }
    }
    
    ans.pb(now);
  }

  for(ss s:ans)co(s);
}
#include<bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    priority_queue<int, vector<int>, greater<int> > pq;
    for (int i=0; i<=200000; i++) pq.push(i);
    priority_queue<int, vector<int>, greater<int> > ers;
    for (int i=1; i<=n; i++) {
        int a; cin>>a;
        ers.push(a);
        while (zmrl(ers)) {
            if (ers.top() > pq.top()) break;
            while (zmrl(ers) && ers.top() < pq.top()) ers.pop();
            if (zmrl(ers) && ers.top() == pq.top()) {
                ers.pop(); pq.pop();
            }
        }
        cout << pq.top() << '\n';
    }
    return 0;
}