P15872 [HackerEarth] There are N boxes.
普及
题目描述

There are N boxes.
'i'th boxes contains c[i] integers.
'i'th box contains only one type of integer a[i].
Find out in how many number of ways we can select integers from the boxes such that their sum is equal to V.
Number of integers selected from the 'i'th box should me in the range of [0,c[i]].

Input :

First line will contain an integer T (number of test case).
Each test case starts with an integer N.
Next line contains N integers,a[i].
Next line contains N integers,c[i].
Next line contains an integer V.

output :

For every test case, print the required answer modulo 10007.
Print the answer for each test case on a new line.

constraints :
0 ≤ c[i] ≤ 4 : if 'i' is even
0 ≤ c[i] ≤ 3 : if 'i' is odd
a[i] ≤ 10^10
V ≤ 10^10
N ≤ 20

Sample output explanation:

10 =0 * 1 + 2 * 2 + 2 * 3
10 =1 * 1 + 0 * 2 + 3 * 3
10 =2 * 1 + 1 * 2 + 2 * 3
10 =3 * 1 + 2 * 2 + 1 * 3
10 =4 * 1 + 0 * 2 + 2 * 3

total ways = 5%10007 = 5

Problem Setter : Mohd Abdullah
Problem Tester :
Shivam Beri

SAMPLE INPUT
1
3
1 2 3
4 2 4
10

SAMPLE OUTPUT
5

输入格式

见题面

输出格式

见题面

样例输入
2 20 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 3 4 4 3 9000000000 20 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 3 2 4 4 1 2 3 4 2 2 3 3 0 1 4 3 4 3 4 3 9000000000
样例输出
8352 4969 9800 9626