#include<bits/stdc++.h>
using namespace std;
int main(){
int T;
cin>>T;
for(int i=1;i<=T;i++){
long long x,y;
cin>>x>>y;
int ops=1;
while (x > 0 && y > 0) {
if(ops==1){
if (x < y){
++x;
}else {
x=x/2;
}
ops=2;
}else{
if (x > y) {
++y;
}else{
y=y/2;
}
ops=1;
}
}
cout<<x<<" "<<y;
}
return 0;
}