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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for(int i = 0; i < num; ++i){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] res = fun(n, k);
            System.out.println(res[0] + " " + res[1]);
        }
    }

    public static int[] fun(int n , int k){
        int maxV = 0;
        if(n <= 2){
            return new int[]{0,0};
        }else if(n - k < k - 1 && (n - k) > 0){
            maxV = n - k;
        }else if(n - k >= k - 1 && (k - 1) > 0){
            maxV = k - 1;
        }
        return new int[]{0, maxV};
    }
}