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 Ai and finishing time Bi (inclusive) of each course i (1 ≤ i ≤ N). You will be also given the number of students registered for each course, Si (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 coursei is taken in a class room, after the class is finished, it takes cleanij time to clean the room to make it tidy for starting teaching coursej immediately just after coursei 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 Input starts with an integer T (T ≤ 100) denoting the number of test cases. 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 Ai, Bi (0 ≤ Ai ≤ Bi ≤ 10000000) and Si (1 ≤ Si ≤ 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 cleanij (1 ≤ i ≤ N, 1 ≤ j ≤ N, 0 ≤ cleanij ≤ 10000000, cleanii = 0). Output For each case, print the test case number, starting from 1, and the answer, minimum number of rooms needed to be hired. Sample Input 3 15 1 60 12 0 41 1 100 10 50 130 3 150 200 15 80 170 7 0234 5078 9 10 0 12 13 14 15 0 21 1 10 1
2/2 12 20 1 02 50 Sample Output Case 1: 3 Case 2: 22 Case 3: 2