InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Another chocolate game

Scooby is a very good mathematics teacher and that is why his students like him. It’s Scooby’s birthday and so he decided to gift chocolates to his students.

Scooby has a total of A different students and he buys B different chocolates for them. He wants to make sure that
each student gets exactly one chocolate. He is interested in knowing the number of ways in which these chocolates can be
distributed to students. As the number of ways can be quite large, he is interested in knowing the number of ways modulo


Number of testcases T: 1<=T<=10000
Number of students of Scooby: 1<=N<=100000
Number of chocolates: 1<=M<=100000


An integer A
An integer B


1. Each student is different
2. Each chocolate is different
3. Each student should get exactly one chocolate
4. Your code will run against multiple test cases (The function in which you run your code will be called T times.)


One integer corresponding to the number of ways of distributing the choclates modulo 1000000007.







Let's say there are three students s1,s2 and s3 and there are three chocolates c1,c2 and c3.
Following is the possible distribution:
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Another chocolate game on Interview Code Editor
Sign Up
to access hints and editorial solutions for Another chocolate game


Click here to start solving coding interview questions