
#include <stdio.h>

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        long long int a, b;
        scanf("%lld", &a);
        scanf("%lld", &b);
        
        if(a == 0)
        {
            printf("%lld 0\n", b);
        }else if(b==0)
        {
            printf("%lld 0\n", a);
        }else if(a == b)
        {
            printf("0 0\n");
        }
         else{
        
            long long int ans = a-b;
            if(ans < 0)
                ans *= -1;
            
            long long int ans1 = (ans - (a%ans));
            long long int ans2 = (a%ans);
            
            if(a % ans == 0)
                printf("%lld 0\n", ans);
            else if(ans2 < ans1)
                printf("%lld %lld\n", ans, ans2);
            else
                printf("%lld %lld\n", ans, ans1);
        }
    }

    return 0;
}
