Box Stacking Problem
You are given a set of n types of rectangular 3-D boxes, where the i^th box has length l(i), width w(i), and height h(i) (all real numbers). You want to create a stack of boxes which is as tall as possible, but you can only stack a box on top of another box if the dimensions of the 2-D base of the lower box are each strictly larger than those of the 2-D base of the higher box. You can rotate a box so that any side functions as its base. It is also allowable to use multiple instances of the same type of box.
In simple statement given problem wants you to arrange the boxes one after the another such that the base of the lower level be greater in size on all four direction than the upper box, you are allowed to rotate the box in all direction you can make, after arranging all the boxes in proper manner you need to print the maximum height that you obtained with them.
The first line of the input is the number of test cases T, each test case consists of number of boxes that is N, following N lines consist of the dimension of each box.
You need to print the maximum height that you can obtain by stacking the boxes in proper order.
4 5 6
8 9 2
6 7 5
4 2 5
3 1 6
3 2 1
6 3 8