#include<iostream>
#include<cmath>
using namespace std;
int main()
{
long long t, x, y;
cin >> t;
for (int i = 1; i <= t; i++)
{
cin >> x >> y;
int num = 1;
while (x != 0 && y != 0)
{
if (num % 2 == 1)
{
if (x < y)
{
x++;
}
else
{
x /= 2;
}
}
else
{
if (y < x)
{
y++;
}
else
{
y /= 2;
}
}
num++;
}
cout << x << " " << y;
}
return 0;
}