https://www.acmicpc.net/problem/9084
import sys
t=int(sys.stdin.readline())
for _ in range(t):
n=int(sys.stdin.readline())
coin=list(map(int, sys.stdin.readline().split()))
money=int(sys.stdin.readline())
dp=[0]*(money+1)
dp[0]=1
for i in coin:
for j in range(i, money+1):
dp[j]+=dp[j-i]
print(dp[money])
for i in coin:
for j in range(i, money+1):
dp[j]+=dp[j-i]