#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
cout<<(x|y)<<" "<<(x&y)<<" "<<(x^y)<<endl;
}
return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
cout<<(x|y)<<" "<<(x&y)<<" "<<(x^y)<<endl;
}
return 0;
}