Under construction

Still being built. Things may change

Birthday Party

Time limit5sMemory limit512 MB

Summary
Count ordered tuples of f positive integers summing to n whose greatest common divisor is 1, modulo 1e9+7, for up to 100000 queries.
Level

Medium7 of 10

Topics
Dynamic programming, Number theory, Combinatorics, Math
Solved
No attempts yet

Problem

Today is Sanggeun's birthday. He invited ff friends to the party and has nn candies to hand out. The friends are numbered from 11 to ff.

Sanggeun hands out the candies under these two rules.

  • Every friend receives at least one candy.
  • Let aia_i be the number of candies friend ii receives. There must be no positive integer x>1x > 1 that divides every aia_i.

Given nn and ff, write a program that counts the ways to hand out the candies.

Two ways are different when some friend receives a different number of candies. For example, giving 1 candy to friend 1 and 2 candies to friend 2 differs from giving 2 candies to friend 1 and 1 candy to friend 2.

Input

The first line contains the number of test cases TT (1≤T≤1000001 \le T \le 100000).

Each of the next TT lines contains nn and ff, separated by a space. (1≤f≤n≤100001 \le f \le n \le 10000)

Output

For each test case, print the number of ways to hand out the candies modulo 10000000071000000007, one per line.

Hint

For n=6n = 6 and f=2f = 2, the possible ways are [1,5][1, 5] and [5,1][5, 1].

For n=7n = 7 and f=2f = 2, the possible ways are [1,6][1, 6], [2,5][2, 5], [3,4][3, 4], [4,3][4, 3], [5,2][5, 2], [6,1][6, 1].

Examples2

  1. Example 1

    Input
    5
    6 2
    7 2
    6 3
    6 4
    7 4
    
    Expected output
    2
    6
    9
    10
    20
    
  2. Example 2

    Input
    1
    1 1
    
    Expected output
    1