/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class GFG {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t!=0){
		    t--;
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int min = Math.min(a,b);
		    int max = Math.max(a,b);
		    
		    int c = max-min;
		    if(c==0){
		        System.out.println("0 0");
		    }else{
		        int d=-1;
		        if(c>=min)
		        d = c-min;
		        else{
		            int d1 = min-c;
		            int d2 = c-(min%c);
		            d=(int)Math.min(d1,d2);
		        }
		        System.out.println(c+" "+d);
		    }
		}
	}
}