#C7560. Beautiful Clusters

    ID: 51445 Type: Default 1000ms 256MiB

Beautiful Clusters

Beautiful Clusters

You are given two integers N and M. Your task is to calculate the number of beautiful clusters modulo \(10^9+7\). A beautiful cluster is defined as selecting N distinct items from M items and then arranging them in order. Mathematically, the number of beautiful clusters is given by:

[ \text{BeautifulClusters}(N, M) = \binom{M}{N} \times N! \mod (10^9+7), \quad \text{if } N \le M, ]

If \(N > M\), the answer is 0.

You are required to answer multiple test cases.

inputFormat

The first line contains an integer T, the number of test cases. Each of the following T lines contains two integers N and M, separated by a space.

outputFormat

For each test case, output a single line containing the number of beautiful clusters modulo \(10^9+7\).

## sample
3
3 3
4 5
2 4
6

120 12

</p>