Hard to Compare
시간 제한4초메모리 제한9 MB
각 테스트케이스의 n과 k에 대해 x가 1부터 k-1까지 변할 때 f(n,k,x)의 가장 큰 값 9개의 합을 1e9+7로 나눈 나머지를 구한다.
문제
Please pay attention to the unusual memory limit.
Let , where , denote the number of integer arrays of length that contain integers from to exactly once, contain integers from to at least twice, and do not contain any other integers. For example, , as there are ways to place , then there are ways to place , and there are ways to place and in the five remaining spots such that both and appear at least twice.
You are given integers and . Find the largest values among , and print their sum modulo .
입력
The input contains one or more test cases. The first line contains the number of test cases ().
The only line of each test case contains two integers and ().
출력
For each test case, output one integer: the sum of largest values modulo .
힌트
In the first test case, , so the answer is just the sum of the remaining nonzero values.