It Can Be Arranged
Every year, several universities arrange inter-university national programming contests. ACM ICPC Dhaka site regional competition is held every year in Dhaka and one or two teams are chosen for ACM ICPC World Finals.
By observing these, MMR (Mission Maker Rahman) has made a plan to open a programming school. In that school n courses are taught. Each course is taught every day (otherwise, programmers may forget DP while learning computational geometry!). You will be given the starting time a_i and finishing time b_i (inclusive) of each course i (1 ≤ i ≤ n). You will be also given the number of students registered for each course s_i (1 ≤ i ≤ n). You can safely assume no student has registered to two different courses. MMR wants to hire some rooms of a building, named Sentinel Tower, for running that school. Each room of Sentinel Tower has a capacity to hold as much as m students. The programmers (students) are very restless and a little bit filthy! As a result, when course i is taken in a class room, after the class is finished, it takes clean_ij time to clean the room to make it tidy for starting teaching course j immediately just after course i in the same room.
Your job is to help MMR to decide the minimum number of rooms need to be hired to run the programming school.
Input
Starts with the number of test cases t (t ≤ 100). Each case starts with two integers n (1 ≤ n ≤ 100), number of courses and m (1 ≤ m ≤ 10000), capacity of a room. Next n lines will contain three integers a_i, b_i (0 ≤ a_i ≤ b_i ≤ 10000000) and s_i (1 ≤ s_i ≤ 10000), starting and finishing time of a course. Next n lines will contain the clean time matrix, where the i^th row will contain n integers clean_ij (1 ≤ i ≤ n, 1 ≤ j ≤ n, 0 ≤ clean_ij ≤ 10000000, clean_{ii }= 0).
Output
For each case, print the test case number, starting from 1, and the answer, minimum number of rooms needed to be hired.