Nayra doesn't like stories of people receiving random arrays as birthday presents, but this time she received random arrays as presents for her own birthday! After struggling for a day trying to figure out what to do with the array, she asked Aryan for help. He gave her the following problem.
You are given integers , and .
For an array , let be defined as the length of the longest strictly increasing subsequence of and let .
Consider all distinct arrays of length such that for all . Calculate the sum of over all such arrays. Since the answer can be huge, print it modulo .
Each test case has queries. For all queries, and remain the same, only varies.
Input Format
- First line will contain , the number of test cases. Then the test cases follow.
- First line of each test case contains three integers and .
- Second line of each test case contains integers, values of for each query.
Output Format
For each testcase, output in a single line containing space-separated integers, answers for each query modulo .
Constraints
Sample Input 1
4
1 1 2
1 2
2 1 2
1 2
2 2 2
1 2
2 1000000 2
1 2
Sample Output 1
1 1
2 5
2 7
2 392816544
Explanation
Test case : In the first query there are distinct arrays. The array is : .
- LIS of . Also, .
Sum of is .
In the second query there are distinct arrays. The array is : .
- LIS of . Also, .
Sum of is .
Test case : In the first query there are distinct arrays. The arrays are : and .
- LIS of . Also, .
- LIS of . Also, . Sum of is .
In the second query there are distinct arrays. The arrays are : and .
- LIS of . Also, .
- LIS of . Also, .
- LIS of . Also, .
- LIS of . Also, .
Sum of is .
No comments:
Post a Comment