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.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class E {	
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

    int MOD = (int) 1e9 + 7;
    public long mod_add(long n1, long n2){
        return (n1 + n2) % MOD;
    }
    public long mod_minus(long n1, long n2){
        return (n1 + MOD - n2) % MOD;
    }
    public long mod_time(long n1, long n2){
        return (n1 * n2) % MOD;
    }
    public long mod_inverse(long n1){
        return mod_inverse(n1, MOD);
    }
    public long mod_inverse(long x, long p) {
        // x^(-1) mod p
        return BigInteger.valueOf(x).modInverse(BigInteger.valueOf(p)).longValue();
    }

    int MAX = (int) 1e5;
    long[] Factorial;
    HashMap<Long, Long> cache = new HashMap<Long, Long>();
	public void solve() throws IOException {
        Factorial = new long[MAX+1];
        Factorial[1] = 1;
        for (int i = 2; i <= MAX; i++) {
            Factorial[i] = mod_time(Factorial[i-1], i);
        }

        int Q = nextInt();
        for (int q = 0; q < Q; q++) {
            int N = nextInt();
            int F = nextInt();

            if (F == 1 && N != 1) {
                out.println(0);
            } else if (F == 1 && N == 1) {
                out.println(1);
            } else {
                out.println(go(N, F));
            }
        }
	}

    public long go(int N, int F) {
        if (N < F) return 0;

        long key = ((long)N << 32) + F;
        if (cache.containsKey(key)) {
            return cache.get(key);
        }

        long sum = nCr(N-1, F-1);
//        out.println("nCr: " + (N-1) + ", " + (F-1) + ": " + sum);

        int[] divisors = getDivisors(N);
        for (int d: divisors) {
            sum = mod_minus(sum, go(N/d, F));
        }

        cache.put(key, sum);

//        out.println("computing: " + N + ", " + F + ": " + cache.get(key));

        return cache.get(key);
    }

    public long nCr (int N, int R) {
        if (R == 0) return 1;
        if (R == N) return 1;
        if (R == 1) return N;
        return mod_time(mod_time(Factorial[N], mod_inverse(Factorial[R])), mod_inverse(Factorial[N - R]));
    }

    public int[] getDivisors(int x){
        int sqrt = (int) Math.sqrt(x);
        int[] ret = new int[ 2*sqrt +1];
        int ret_size = 0;

        for(int i = 2; i <= sqrt; i++){
            if( x % i == 0){
                ret[ret_size++] = i;
                if( i != x/i)
                    ret[ret_size++] = x/i;
            }
        }
        ret = Arrays.copyOf(ret, ret_size);
        return ret;
    }

    // prime numbers
    public int[] getPrimeNumbers(int max){
        boolean[] table = getPrimeTable(max);
        int size = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]) size++;
        }
        int[] rets = new int[size];
        int current = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]){
                rets[current++] = i;
            }
        }
        return rets;
    }
    public boolean[] getPrimeTable(int max){
        boolean[] isPrime = new boolean[max+1];
        for(int i = 2; i <= max; i++){
            isPrime[i] = true;
        }
        for(int i = 2; i <= max; i++){
            if(isPrime[i]){
                for(int j = i+i; j <= max; j+=i){
                    isPrime[j] = false;
                }
            }
        }
        return isPrime;
    }
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new E().run();
	}
	
	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}
