Contest Problem Assignment

No attempts yetTime limit1sMemory limit128 MB

Problem

A team of three is competing in a programming contest. All three have read every problem and estimated, for each one, how many minutes it would take that person to solve it. The team now wants to split the problems so that it solves as many of them as possible in the time that is left.

Every member writes the whole solution out on paper before sitting down at the computer, so nobody ever waits for the machine. Only one condition applies: for each team member, the estimated solving times of the problems that member takes must add up to no more than the time left in the contest.

A problem goes to at most one member, and a member cannot be given a problem that person is unable to solve.

Input

The first line has the number of test cases tt (1t1001 \le t \le 100). Each test case is given as follows.

  • One line with the number of problems nn (1n101 \le n \le 10) and the number of minutes left in the contest mm (1m3001 \le m \le 300).
  • Three lines with nn integers each. Line ii holds the solving times of the iith team member, and the jjth integer on that line, sijs_{ij}, is the time in minutes that member needs for problem jj (1sij3001 \le s_{ij} \le 300). It is 1-1 if that member cannot solve the problem.

Output

For each test case, print on one line the largest number of problems the team can solve.