#442. Tree Planting
Tree Planting
Description
There are buildings on the side of Bytestreet, standing sequentially one next to the other, labeled by from east to west. The city planning investigation is going to plant some trees in front of these buildings. A tree planting plan is beautiful if and only if it satisfies all the conditions below:
- At least one tree is planted.
- A tree can only be planted in front of a building, and two trees can not be planted in front of the same building. In other words, let denote the number of trees planted in front of the -th building, holds for all .
- For every possible value of (), and shouldn't both be .
- For every possible value of (), and shouldn't both be . The beautifulness of a plan is defined as:[\prod_{1\leq i\leq n,c_i=1}w_i]You need to find the sum of beautifulness among all the beautiful plans. Two plans are considered different if there exists any () such that they differ in .
Format
Input
The first line contains a single integer (), the number of test cases. For each test case:
The first line contains two integers and (), denoting the number of buildings and the value of .
The second line contains integers ().
It is guaranteed that there will be at most test cases such that .
Output
For each test case, output a single line containing an integer, denoting the sum of beautifulness among all the beautiful plans. Note that the answer may be extremely large, so please print it modulo instead.
Samples
2
5 3
1 1 1 1 1
5 4
1 2 3 4 5
10
55