We want to distribute 'n' indistinguishable one Rupees coins among 'k' pupils, such that each of them receives at least one Rupees.

We have to count the number of ways, we can distribute the amount under the given condition? Note:

Two distributions are said to be different if they have at least one pupil who got a different amount of rupees.

Since, the answer can be very large, Output it modulo 1000000007

**Input:**

The first line contains an Integer 't' denoting the number of test cases.

Each of the next t lines contains two Integers - n and k.

**Output:**

Print the total number of different such distributions Modulo 1000000007 for each test case on a new line

**Constraints:**

1 ≤ n,k ≤ 1000000

1 ≤ t ≤ 1000

**Example:**

**Input:**

1

7 3

**Output:**

15

**Explanation:**

We can give These amounts to its pupils.

1,1,5

1,5,1

5,1,1

2,1,4

1,2,4

1,4,2

2,4,1

4,1,2

4,2,1

3,1,3

1,3,3

3,3,1

2,2,3

2,3,2

3,2,2

so,In Total 15 ways.

Author: iamabjain

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

preparecodinginterview_dot_com | 190 |

__murugan__ | 171 |

manvimahajan20 | 134 |

ShameekAgarwal | 116 |

SoumyaKaushik | 108 |

preparecodinginterview_dot_com | 190 |

__murugan__ | 171 |

manvimahajan20 | 160 |

SoumyaKaushik | 146 |

arpit_anshuman | 140 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.