Counting Coin Combinations

Time limit1sMemory limit128 MB

Problem

Given several coin denominations and a target amount, count how many distinct combinations of coins can make that amount.

Each denomination may be used any number of times. Two ways that differ only by the order of the coins are considered the same combination.

Input

The first line contains the number of test cases T.

Each test case consists of three lines.

  • The first line contains the number of coin denominations N (1 <= N <= 20).
  • The second line contains the N coin values in increasing order. Each value is an integer from 1 to 10000.
  • The third line contains the target amount M (1 <= M <= 10000).

You may assume that the number of combinations is less than $2^{31}-1$.

Output

For each test case, print one line containing the number of combinations that make amount M using the given denominations.