#include <iostream>
#include <algorithm>
using namespace std;
void wypelnij( int t[10000], int rozmiar )
{
for (int i=0;i<10000;i++){
if (i<rozmiar) cin>> t[i];
else t[i]=0;}
}
int main()
{
int d;
cin>>d;
for(int j=0;j<d;j++){
short int n,m,maks;
cin>> n;
int a[10000];
wypelnij(a,n);
cin>> m;
int b[10000];
wypelnij(b,m);
reverse(a,a+n);
reverse(b,b+m);
maks=max(n,m);
/*for (int i=0;i<100;i++) cout<< a[i]<<" ";
cout<<endl;
for (int i=0;i<100;i++) cout<< b[i]<<" ";*/
int wynik[maks];
int reszta = 0;
for (int i=0;i<maks;i++){
wynik[i] = (a[i] + b[i] + reszta) % 2;
reszta = (a[i] + b[i] + reszta) / 2;
if (reszta > 0) wynik[i+1] = reszta;
}
reverse(wynik,wynik+maks);
if (reszta > 0) cout<<"1";
for (int i=0;i<maks;i++) cout<< wynik[i];
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCB3eXBlbG5paiggaW50IHRbMTAwMDBdLCBpbnQgcm96bWlhciApCnsKICAgIGZvciAoaW50IGk9MDtpPDEwMDAwO2krKyl7CiAgICAgICAgaWYgKGk8cm96bWlhcikgY2luPj4gdFtpXTsKICAgICAgICBlbHNlIHRbaV09MDt9Cn0KCmludCBtYWluKCkKewogICAgaW50IGQ7CiAgICBjaW4+PmQ7CiAgICBmb3IoaW50IGo9MDtqPGQ7aisrKXsKICAgICAgIHNob3J0IGludCBuLG0sbWFrczsKICAgICAgIGNpbj4+IG47CiAgICAgICBpbnQgYVsxMDAwMF07CiAgICAgICB3eXBlbG5paihhLG4pOwogICAgICAgY2luPj4gbTsKICAgICAgIGludCBiWzEwMDAwXTsKICAgICAgIHd5cGVsbmlqKGIsbSk7CiAgICAgICByZXZlcnNlKGEsYStuKTsKICAgICAgIHJldmVyc2UoYixiK20pOwogICAgICAgbWFrcz1tYXgobixtKTsK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