#T445. OJ积分购物
OJ积分购物
Description
Xiao Wei, as a COIer, frequently submits and solves problems on OJ platforms, earning various types of points.
Xiao Wei has four types of OJ points with denominations of , , , and .
Xiao Wei goes shopping and makes purchases. For each purchase, he carries coins of the -th type of points and wants to buy an item worth . Determine the number of ways he can pay for each purchase.
Input Format
The first line of input contains five integers: , , , , and .
The next lines each describe a purchase with five integers: , , , , and .
Output Format
For each purchase, output a single integer representing the number of payment methods.
1 2 5 10 2
3 2 3 1 10
1000 2 2 2 900
4
Hint
【Data Range】
For 100% of the data, it is guaranteed that , and .
Source
Adapted from a 2008 provincial selection problem.