Unlock the Door
Practice
3.5 (53 votes)
Easy
Math
Problem
36% Success 15203 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Our Friend Monk has finally found the Temple of Programming secrets. However, the door of the temple is firmly locked. Now, as per the rules of the temple, Monk needs to enter a Secret Password in a special language to unlock the door. This language, unlike English consists of K alphabets. The properties of this secret password are:

  1. It has a length of N characters.

  2. It is composed only of the K characters belonging to the Special language.

  3. Each character belonging to the special language has been used at max once in the secret code.

Now, Monk has no idea about what the ideal password may be and needs you help. You need to help Monk find the total number of distinct candidate Strings for it Modulo \(10^9+7\).

Input Format:

The first line contains a single integer T denoting the number of test cases. Each of the next T lines contain two integers N and K denoting the length of the Secret Password and the number of characters of the Special language to be used respectively.

Output Format:

For each test case, output the number of possible distinct secret passwords Modulo \(10^9+7\).

Constraints:

\( 1 \le T \le 10 \)

\( 1 \le N \le K \le 10^5 \)

Note:

You need to print the value of each element and not their weight.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
262 votes
Tags:
ApprovedEasyMathNumber TheoryReady
Points:30
24 votes
Tags:
AlgorithmsApprovedEasyOpen
Points:30
29 votes
Tags:
ApprovedEasyMathNumber theory