- Time limit: 3.00 s
- Memory limit: 512 MB
Uolevi works at a giant megacorporation warehouse. Now that he has stacked all the boxes that have stuff in them, he is going to build the tallest possible pyramid from the empty boxes. There are boxes numbered , the -th of which has width , depth and height . A tower of boxes is called a pyramid if and applies to all pairs of boxes where box is on top of box . Find the height of the tallest possible pyramid Uolevi can construct.
Input
The first line contains a single integer . The -th of the next lines contains three integers , , and .
Output
Print the height of the tallest possible pyramid.
Constraints
Example 1
Input:
5 5 10 8 10 1 2 4 10 2 3 1 4 2 4 4
Output:
14
Example 2
Input:
10 5 2 1 10 6 10 5 5 5 4 4 2 3 7 7 2 3 5 3 7 7 9 6 7 2 5 6 6 2 8
Output:
33
Example 3
Input:
1 1000000000 1000000000 1000000000
Output:
1000000000