SP25458 BUD13TLF - Boxes

Description

Given n boxes with widths of w1, w2, . . . , wn and another big box with width W, find how many ways the boxes can be put in the big box. The constrains are: 1\) Of course the summation of widths of the placed boxes should not be greater than W. 2\) The boxes should be placed one by one starting from left without leaving any empty spaces between them. So, the end of the big box may contain empty spaces. But if there is any unplaced box which can be fit in this space, the ordering should be considered invalid (See the explanation for sample case 1). 3\) Two orderings are considered different if in one ordering, one box is in i-th position, but in another ordering, it isn’t. 4\) If two boxes have same widths, they should be considered same

Input Format

Input starts with an integer T ( Each case starts two integers n (1

Output Format

For each case, print the case number first and the result modulo 10007.