Turbulent Teamwork
Tag(s):

## Medium

Problem
Editorial
Analytics

The government of virtualBit has N ministers. The importance and type of the ith minister is Ai and Pi. The ministers have decided that the best way to solve the issues quickly is to divide themselves into two groups. The two groups should satisfy the following:

1. The difference in total importance of ministers of a group must be less than or equal to B.

2. The ministers work efficiently when they have another minister from the same group and type to brain-storm ideas with. So, ministers of the same type belonging to same group form pairs. The total number of ministers in both groups that do not belong to any pair should be less than or equal to Q.

Your task is to find the total number of ways in which the two groups can be formed.

Input

The first line contains T, the number of test-cases.

T test cases follow.

The first line of each test case contains N, B and Q.

The second line of each test case contains N numbers. The ith number is Ai

The third line of each test case contains N numbers. The ith number is Pi

Output

For each test case, output a single line containing the number of ways in which the groups can be made.

Since the answer can be very large, output the number of ways modulo 1000000007 (109+7)

Constraints

1 <= T <= 10

1 <= N <= 100

0 <= Ai <= 100

1 <= Pi <= 5

0 <= B <= 104

0 <= Q <= N

SAMPLE INPUT
2
5 1 1
1 2 3 4 5
2 1 1 1 2
5 10 4
1 1 1 1 1
1 2 3 4 5
SAMPLE OUTPUT
1
0
Explanation

In the first case, the only possible way to make two groups are {1,2,5} and {3,4}. This ensures that the difference in sum of two groups is 8 - 7 = 1 and the only unpaired minister is 2

In the second case, there is no way to ensure that the total number of unpaired ministers is <= 4

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

Programmers' Parliament

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Graphs
• Algorithms > Dynamic Programming