The first line of the input is Z ≤ 20 the number of test cases. This is followed by Z test cases. Each test case begins with three space-separated integers: C, T, and L. Each of the following C× T lines gives, respectively, the location and energy consumption of a class. The first T lines represent the classes of category 1, the next T lines represent the classes of category 2, and so on. No two classes in the same category will have the same location.
Bounds:
1 ≤ C ≤ 25
1 ≤ T ≤ 1000
1 ≤ L ≤ 1,000,000
1 ≤ Eij ≤ 1,000,000
0 ≤ Pij ≤ L