#include<stdio.h>
int judge(int x)
{
int p[110],k,i,t,num;
k=0;
if(x<0)
{
x=-x;
k=1;
}
num=1;
while(x)
{
p[num++]=x%10;
x=x/10;
}
t=0;
for(i=1;i<num;i++)
t=t*10+p[i];
if(k)
return -t;
else return t;
}
int main()
{
int n,a,b,x,y,s1,s2;
scanf("%d",&n);
while(n--)
{
scanf("%d %d",&x,&y);
a=(x+y)/2;
b=(x-y)/2;
s1=judge(a);
s2=judge(b);
printf("%d %d\n",s1+s2,s1-s2);
}
return 0;
}