Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ensure to give at least one sweet to each friend. 

He wants to celebrate it in a unique style, so he would like to ensure following condition for the distribution of sweets. Assume that he has distributed n sweets to his friends such that ith friend is given ai sweets. He wants to make sure that there should not be any positive integer x > 1, which divides every ai.

Please find the number of ways he can distribute sweets to his friends in the required way. Note that the order of distribution is important, for example [1, 2] and [2, 1] are distinct distributions. As the answer could be very large, output answer modulo 1000000007 (109 + 7).

To make the problem more interesting, you are given q queries. Each query contains an n, f pair. For each query please output the required number of ways modulo 1000000007 (109 + 7).

Input

The first line contains an integer q representing the number of queries (1 ≤ q ≤ 105). Each of the next q lines contains two space space-separated integers n, f (1 ≤ f ≤ n ≤ 105).

Output

For each query, output a single integer in a line corresponding to the answer of each query.

Examples

Input

5
6 2
7 2
6 3
6 4
7 4


Output

2
6
9
10
20

Note

For first query: n = 6, f = 2. Possible partitions are [1, 5] and [5, 1].

For second query: n = 7, f = 2. Possible partitions are [1, 6] and [2, 5] and [3, 4] and [4, 3] and [5, 3] and [6, 1]. So in total there are 6 possible ways of partitioning.
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;

/**
 *
 * @author sousnake
 */
public class E {
    static long fact[] ;
    static int MAX = (int) 1e5;
    static int mod = (int) 1e9+7;
    static HashMap<Long,Long> mp =new HashMap<Long,Long>();
    public static void main(String as[]) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        fact=new long[MAX+1];
        fact[1]=1;
        for(int i=2;i<=MAX;i++){
            fact[i]=(fact[i-1]*i)%mod;
        }
        int q = Integer.parseInt(br.readLine());
        StringBuilder sb =new StringBuilder();
        for(int t=0;t<q;t++){
            String s1[] = br.readLine().split(" ");
            int n = Integer.parseInt(s1[0]);
            int f = Integer.parseInt(s1[1]);
            if(f==1&&n!=1){
                sb.append(0+""+'\n');
            }
            else if(f==1&&n==1){
                sb.append(1+""+'\n');
            }
            else{
                sb.append(cal(n,f)+""+'\n');
            }
        }
        System.out.print(sb.toString());
    }
    public static long cal(int n, int f){
        if(n<f)
            return 0;
        long key= ((long)n<<32)+f;
        if(mp.containsKey(key))
            return mp.get(key);
        long sum  = ncr(n-1,f-1);
        int []div = getdiv(n);
        
        for(int d:div){
            //System.out.println("return n = "+n+" f = "+f+" div= "+d);
            sum = (sum-cal(n/d,f)+mod)%mod;
            
        }
        mp.put(key, sum);
        //System.out.println("return n = "+n+" f = "+f+" sum = "+sum);
        return sum;
    }
    
    public static long modinve(long n1){
        return modinve(n1, mod);
    }
    public static long modinve(long x, long p) {
        // x^(-1) mod p
        return BigInteger.valueOf(x).modInverse(BigInteger.valueOf(p)).longValue();
    }
    public static long modmul(long n1, long n2){
        return (n1 * n2) % mod;
    }
    public static long ncr (int N, int R) {
        if (R == 0) return 1;
        if (R == N) return 1;
        if (R == 1) return N;
        return modmul(modmul(fact[N], modinve(fact[R])), modinve(fact[N - R]));
    }
    public static int[] getdiv(int n){
        int sq = (int)Math.sqrt(n);
        int arr[] = new int[2*sq+1];
        int size=0;
        for(int i=2;i<=sq;i++){
            if(n%i==0){
                arr[size]=i;
                size++;
                if(i!=n/i){
                    arr[size]=n/i;
                    size++;
                }
            }
        }
        arr= Arrays.copyOf(arr, size);
        //System.out.println(sq+" "+size+" "+n);
        return arr;
    }
}
