P19586 [HackerEarth] Ahmed found a bag having many coins in it of ₹1, ₹2, ₹5 and ₹10. One of his best friend Abdul need ₹R urgently so he asked Ahmed for it. Ahmed want to know all the possibilities in which
普及
题目描述

Ahmed found a bag having many coins in it of ₹1, ₹2, ₹5 and ₹10. One of his best friend Abdul need ₹R urgently so he asked Ahmed for it. Ahmed want to know all the possibilities in which he can give money to Abdul using all coins which are with him.
Your task is to find out number of ways in which total money can be given with using available coins only i.e,. in how many ways we can sum them(coins) up to form a total of ₹R.

Input Format:

The first line contains an integer T which is number of test cases. Each test case contains 2 lines. The first line contains integer R (Rupee to be achieved)
a, b, c and d in the next line, each representing the number of ₹1, ₹2, ₹5 and ₹10 coins respectively.

Output Format:

Output the number of ways in which we can achieve the sum R

Constraints:

1 ≤ T ≤ 200

1 ≤ R ≤ 1000

1 ≤ a ≤ 10000

1 ≤ b,c,d ≤ 1000

SAMPLE INPUT
2
15
2 3 1 1
12
2 2 1 1

SAMPLE OUTPUT
2
2

Explanation

For case 1 we need to find the different ways to get sum total to 15. So we can use one ₹10 coin and one ₹5 coin or we can use one ₹10 coin two ₹2 coin and one ₹1 coin. So, 2 ways to achieve this.

For case 2 we need to find the different ways to get sum total to 12. So we can use one ₹10 coin and one ₹2 coin or we can use one ₹10 coin two ₹1 coin. So, there are 2 ways to achieve this.

输入格式

见题面

输出格式

见题面

样例输入
5 87 46 11 9 11 66 32 41 18 4 29 42 12 5 7 54 12 28 5 5 86 39 33 11 9
样例输出
74660 36305 73869 279541 12259 34542 190330 1876 77688 1980 161636 42664 0 365735 143673 113456 6078 227686 111925 133838 88847 275 51763