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.

cs_abhi | 62 |

kya_bolti_public | 56 |

Shubhankar Sharma | 44 |

vermaankush14291 | 42 |

coderquill | 40 |

PiyushPandey4 | 856 |

john_wick | 757 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

UsfShilpa | 536 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.