#include<bits/stdc++.h>
using namespace std;
int a,b,c,t;
queue<int>q;
int main()
{
cin>>t;
while(t--)
{
cin>>a>>b>>c;
if( a==b && b==0 && c )
{
cout<<-1<<endl;
continue;
}
if( !c )
{
while( b )
{
q.push( 2 );
b/=2;
}
b^=a;
q.push( 4 );
a^=b;
q.push(3);
while( b )
{
q.push( 2 );
b/=2;
}
cout<<q.size()<<endl;
while( q.size() )
{
cout<<q.front()<<' ';
q.pop();
}
cout<<endl;
continue;
}
if( !b )
{
b^=a;
q.push( 4 );
}
while( b!=1 )
{
b>>=1;
q.push(2);
}
if( !a )
{
a^=b;
q.push(3);
}
else{
b=a^b;
q.push(4);
a^=b;
q.push(3);
}
while( b )
{
b/=2;
q.push(2);
}
//cout<<"??"<<a<<' '<<b<<' '<<c<<endl;
while( (a^b)!=c )
{
if( a&c )
{
b^=a;
q.push(4);
}
a<<=1;
q.push(1);
}
a^=b;
q.push(3);
while(b)
{
b/=2;
q.push( 2 );
}
b^=a;
q.push(4);
cout<<q.size()<<endl;
while( q.size() )
{
cout<<q.front()<<' ';
q.pop();
}
cout<<endl;
}
}