#SDNU1508. F.Feed the monkey

F.Feed the monkey

Description

Alice has a monkey, she must feed fruit to the monkey every day.She has three kinds of fruits, bananas, peaches and apples. Every day, she chooses one in three, and pick one of this to feed the monkey. But the monkey is picky, it doesn’t want bananas for more than D1D1 consecutive days, peaches for more than D2D2 consecutive days, or apples for more than D3 consecutive days. Now Alice has N1bananas,N2peachesandN3N1 bananas, N2 peaches and N3 apples, please help her calculate the number of schemes to feed the monkey.

Input

Multiple test cases. The first line contains an integer T(T20)T (T \leq 20), indicating the number of test case. Each test case is a line containing 66 integers $N1, N2, N3, D1, D2, D3 (N1, N2, N3, D1, D2, D3 \leq 50)$.

Output

One line per case. The number of schemes to feed the monkey during (N1+N2+N3) days. The answer is too large so you should mod 10000000071000000007.

Sample Input

1
2 1 1 1 1 1

Sample Output

6

Hints

Answers are BPBA, BPAB, BABP, BAPB, PBAB, and ABPB(B-banana P-peach A-apple)