import java.util.*;
public class HelloWorld{

     public static void main(String []args){
        Scanner scn = new Scanner(System.in);
        long t = scn.nextInt();
        while(t-- > 0){
            long a = scn.nextInt();
            long b = scn.nextInt();
            if(a == b){
                System.out.println(0 + " " + 0);
            }else if(a-b == 1 || b-a == 1){
                System.out.println(1 + " " + 0);
            }else{
                long gcd = Math.abs(a-b);
                System.out.print(gcd + " ");
                if(a> b){
                    long moves = gcd - (a%gcd);
                    System.out.println(moves);
                }else{
                    long moves = gcd - (b%gcd);
                    System.out.println(moves);
                }
            }
        }
     }
}