#include <iostream>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin>>k;
    while(k--){
        int x,y;
        cin>>x>>y;
        cout<<(x|y)<<" "<<(x&y)<<" "<<(x^y)<<endl;
    }
}