#include<bits/stdc++.h>
using namespace std;
template<typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
typename vector<T>::const_iterator it;
for (it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) os << ", ";
os << *it;
}
return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
os << "[";
typename set<T>::const_iterator it;
for (it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) os << ", ";
os << *it;
}
return os << "]";
}
template<typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
os << "[";
typename map<F, S>::const_iterator it;
for (it = v.begin(); it != v.end(); it++) {
if (it != v.begin()) os << ", ";
os << it->first << " = " << it->second;
}
return os << "]";
}
#define debug(x) cerr << #x << " = " << x << endl;
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef map<int, int> mii;
typedef vector< pair<int, int> > vpii;
#define endl "\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c),x) != (c).end())
#define F first
#define S second
const ld PI=acos(-1.0);
const ll mod = 1000000007;
const ll inf = (ll) 1e15;
ll power(ll a, ll b, ll m = mod) {if (b == 0) return 1; if (b == 1) return (a % m); ll x = power(a, b / 2, m); x = (x * x) % m; if (b % 2) x = (x * a) % m;return x;}
ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
const int N=1e5+5;
const int M=1e5+5;
void solve() {
int a1[11]={0},a2[11]={0},a3[11]={0};
int c1=0,c2=0,c3=0;
string s1,s2,s3;
cin >> s1 >> s2 >> s3;
for(int i=0;i<10;i++)
{
if(s1[i]=='1')
c1++;
if(s2[i]=='1')
c2++;
if(s3[i]=='1')
c3++;
}
set<int> s;
for(int i=1;i<=c1;i++)
{
a1[i]=1;
s.insert(i);
}
bool used1[11]={false};
for(int i=c1+1;c2>0&&i<=10;i++)
{
used1[i]=true;
a2[i]=1;
s.insert(i);
c2--;
}
if(c2>0)
{
while(c2>0)
{
int torem=-1;
for(auto it : s)
{
if(used1[it]== false)
torem=it;
}
s.erase(torem);
used1[torem]=true;
c2--;
}
}
assert(c2==0);
bool used[11]={false};
for(int i=1;c3>0&&i<=10;i++)
{
if(s.find(i)!=s.end())
continue;
used[i]=true;
s.insert(i);
c3--;
}
if(c3>0)
{
while(c3>0)
{
int torem=-1;
for(auto it : s)
{
if(used[it]== false)
torem=it;
}
s.erase(torem);
used[torem]=true;
c3--;
}
}
assert(c3==0);
// debug(s);
string ans="";
for(int i=1;i<=10;i++)
{
int p=0;
if(s.find(i)!=s.end())
p=1;
ans+=(char)(p+'0');
}
sort(ans.begin(),ans.end());
reverse(ans.begin(),ans.end());
cout << ans << endl;
}
int main() {
IOS;
int t = 1, num = 1; ///// change this t for number of testcase globally
cin >> t;
while (t--) {
solve();
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnRlbXBsYXRlPHR5cGVuYW1lIEYsIHR5cGVuYW1lIFM+Cm9zdHJlYW0gJm9wZXJhdG9yPDwob3N0cmVhbSAmb3MsIGNvbnN0IHBhaXI8RiwgUz4gJnApIHsKICAgIHJldHVybiBvcyA8PCAiKCIgPDwgcC5maXJzdCA8PCAiLCAiIDw8IHAuc2Vjb25kIDw8ICIpIjsKfQoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kb3N0cmVhbSAmb3BlcmF0b3I8PChvc3RyZWFtICZvcywgY29uc3QgdmVjdG9yPFQ+ICZ2KSB7CiAgICBvcyA8PCAieyI7CiAgICB0eXBlbmFtZSB2ZWN0b3I8VD46OmNvbnN0X2l0ZXJhdG9yIGl0OwogICAgZm9yIChpdCA9IHYuYmVnaW4oKTsgaXQgIT0gdi5lbmQoKTsgaXQrKykgewogICAgICAgIGlmIChpdCAhPSB2LmJlZ2luKCkpIG9zIDw8ICIsICI7CiAgICAgICAgb3MgPDwgKml0OwogICAgfQogICAgcmV0dXJuIG9zIDw8ICJ9IjsKfQoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kb3N0cmVhbSAmb3BlcmF0b3I8PChvc3RyZWFtICZvcywgY29uc3Qgc2V0PFQ+ICZ2KSB7CiAgICBvcyA8PCAiWyI7CiAgICB0eXBlbmFtZSBzZXQ8VD46OmNvbnN0X2l0ZXJhdG9yIGl0OwogICAgZm9yIChpdCA9IHYuYmVnaW4oKTsgaXQgIT0gdi5lbmQoKTsgaXQrKykgewogICAgICAgIGlmIChpdCAhPSB2LmJlZ2luKCkpIG9zIDw8ICIsICI7CiAgICAgICAgb3MgPDwgKml0OwogICAgfQogICAgcmV0dXJuIG9zIDw8ICJdIjsKfQoKdGVtcGxhdGU8dHlwZW5hbWUgRiw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YgZmlyc3QKI2RlZmluZSBTIHNlY29uZAoKCmNvbnN0IGxkIFBJPWFjb3MoLTEuMCk7CmNvbnN0IGxsIG1vZCA9IDEwMDAwMDAwMDc7CmNvbnN0IGxsIGluZiA9IChsbCkgMWUxNTsKCmxsIHBvd2VyKGxsIGEsIGxsIGIsIGxsIG0gPSBtb2QpIHtpZiAoYiA9PSAwKSByZXR1cm4gMTsgaWYgKGIgPT0gMSkgcmV0dXJuIChhICUgbSk7IGxsIHggPSBwb3dlcihhLCBiIC8gMiwgbSk7IHggPSAoeCAqIHgpICUgbTsgaWYgKGIgJSAyKSB4ID0gKHggKiBhKSAlIG07cmV0dXJuIHg7fQpsbCBtYXgobGwgYSwgbGwgYikgeyByZXR1cm4gKGEgPiBiID8gYSA6IGIpOyB9CmxsIG1pbihsbCBhLCBsbCBiKSB7IHJldHVybiAoYSA8IGIgPyBhIDogYik7IH0KCmNvbnN0IGludCBOPTFlNSs1Owpjb25zdCBpbnQgTT0xZTUrNTsKCnZvaWQgc29sdmUoKSB7CgogICAgaW50IGExWzExXT17MH0sYTJbMTFdPXswfSxhM1sxMV09ezB9OwogICAgaW50IGMxPTAsYzI9MCxjMz0wOwogICAgc3RyaW5nIHMxLHMyLHMzOwogICAgY2luID4+IHMxID4+IHMyID4+IHMzOwogICAgZm9yKGludCBpPTA7aTwxMDtpKyspCiAgICB7CiAgICAgICAgaWYoczFbaV09PScxJykKICAgICAgICAgICAgYzErKzsKICAgICAgICBpZihzMltpXT09JzEnKQogICAgICAgICAgICBjMisrOwogICAgICAgIGlmKHMzW2ldPT0nMScpCiAgICAgICAgICAgIGMzKys7CiAgICB9CiAgICBzZXQ8aW50PiBzOwogICAgZm9yKGludCBpPTE7aTw9YzE7aSsrKQogICAgewogICAgICAgIGExW2ldPTE7CiAgICAgICAgcy5pbnNlcnQoaSk7CiAgICB9CiAgICBib29sIHVzZWQxWzExXT17ZmFsc2V9OwogICAgZm9yKGludCBpPWMxKzE7YzI+MCYmaTw9MTA7aSsrKQogICAgewogICAgICAgIHVzZWQxW2ldPXRydWU7CiAgICAgICAgYTJbaV09MTsKICAgICAgICBzLmluc2VydChpKTsKICAgICAgICBjMi0tOwogICAgfQogICAgaWYoYzI+MCkKICAgIHsKICAgICAgICB3aGlsZShjMj4wKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHRvcmVtPS0xOwogICAgICAgICAgICBmb3IoYXV0byBpdCA6IHMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKHVzZWQxW2l0XT09IGZhbHNlKQogICAgICAgICAgICAgICAgICAgIHRvcmVtPWl0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIHMuZXJhc2UodG9yZW0pOwogICAgICAgICAgICB1c2VkMVt0b3JlbV09dHJ1ZTsKICAgICAgICAgICAgYzItLTsKICAgICAgICB9CiAgICB9CgogICAgYXNzZXJ0KGMyPT0wKTsKCiAgICBib29sIHVzZWRbMTFdPXtmYWxzZX07CiAgICBmb3IoaW50IGk9MTtjMz4wJiZpPD0xMDtpKyspCiAgICB7CiAgICAgICAgaWYocy5maW5kKGkpIT1zLmVuZCgpKQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB1c2VkW2ldPXRydWU7CiAgICAgICAgcy5pbnNlcnQoaSk7CiAgICAgICAgYzMtLTsKICAgIH0KICAgIGlmKGMzPjApCiAgICB7CiAgICAgICAgd2hpbGUoYzM+MCkKICAgICAgICB7CiAgICAgICAgICAgIGludCB0b3JlbT0tMTsKICAgICAgICAgICAgZm9yKGF1dG8gaXQgOiBzKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZih1c2VkW2l0XT09IGZhbHNlKQogICAgICAgICAgICAgICAgICAgIHRvcmVtPWl0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIHMuZXJhc2UodG9yZW0pOwogICAgICAgICAgICB1c2VkW3RvcmVtXT10cnVlOwogICAgICAgICAgICBjMy0tOwogICAgICAgIH0KICAgIH0KCiAgICBhc3NlcnQoYzM9PTApOwoKICAgLy8gZGVidWcocyk7CiAgICBzdHJpbmcgYW5zPSIiOwogICAgZm9yKGludCBpPTE7aTw9MTA7aSsrKQogICAgewogICAgICAgIGludCBwPTA7CiAgICAgICAgaWYocy5maW5kKGkpIT1zLmVuZCgpKQogICAgICAgICAgICBwPTE7CiAgICAgICAgYW5zKz0oY2hhcikocCsnMCcpOwogICAgfQogICAgc29ydChhbnMuYmVnaW4oKSxhbnMuZW5kKCkpOwogICAgcmV2ZXJzZShhbnMuYmVnaW4oKSxhbnMuZW5kKCkpOwogICAgY291dCA8PCBhbnMgPDwgZW5kbDsKCn0KCmludCBtYWluKCkgewogICAgSU9TOwogICAgaW50IHQgPSAxLCBudW0gPSAxOyAgIC8vLy8vIGNoYW5nZSB0aGlzIHQgZm9yIG51bWJlciBvZiB0ZXN0Y2FzZSBnbG9iYWxseQogICAgY2luID4+IHQ7CiAgICB3aGlsZSAodC0tKSB7CiAgICAgICAgc29sdmUoKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cgo=